Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separating GCP and home deployment flows #95

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/deploy-home.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
name: Deploy to Kubernetes on Fats

on:
push:
pull_request:
types:
- closed
branches:
- main
workflow_run:
workflows: [ "Build Image" ]
types:
- completed

jobs:
deploy:
Expand Down
63 changes: 2 additions & 61 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: Deploy to Google Cloud
name: Build Image

on:
pull_request:
types:
- closed
branches:
- main
push:
branches:
- main
workflow_run:
workflows: [ "Run Tests" ]
types:
Expand Down Expand Up @@ -47,40 +44,6 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt

- id: 'test'
name: Test with pytest
env:
ENV: dev
SECRET_KEY: '${{ secrets.SECRET_KEY }}'
run: |
pytest

# Alternative option - authentication via credentials json
- id: 'auth'
name: 'Authenticate with Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'

# Authenticate Docker to Google Cloud Artifact Registry
- name: 'Authenticate with Google Cloud Artifact Registry'
uses: 'docker/login-action@v3'
with:
username: '_json_key'
password: '${{ secrets.GCP_CREDENTIALS }}'
registry: '${{ env.REGION }}-docker.pkg.dev'

- name: 'Build and Push Container to Google Cloud Artifact Registry'
id: 'build-image'
env:
SECRET_KEY: '${{ secrets.SECRET_KEY }}'
uses: 'docker/build-push-action@v5'
with:
push: true
tags: '${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.ARTIFACT_REPO }}/${{ env.SERVICE }}:${{ github.sha }}'
# NOTE: If using a pre-built image, update the image name here
# tags: '${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}'

- name: 'Authenticate with GitHub Container Registry'
uses: 'docker/login-action@v1'
with:
Expand All @@ -93,26 +56,4 @@ jobs:
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}/${{ env.SERVICE }}:${{ github.sha }}

- name: 'Deploy to Cloud Run'
id: 'deploy'
uses: 'google-github-actions/deploy-cloudrun@v2'
with:
env_vars: |
ENV=prod
DB_HOST=aws.connect.psdb.cloud
DB_NAME=crank
secrets: |
DB_USER=DB_USER:latest
DB_PASS=DB_PASS:latest
SECRET_KEY=SECRET_KEY:latest

service: '${{ env.SERVICE }}'
region: '${{ env.REGION }}'
# NOTE: If using a pre-built image, update the image name here
image: '${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.ARTIFACT_REPO }}/${{ env.SERVICE }}:${{ github.sha }}'

# If required, use the Cloud Run url output in later steps
- name: 'Show Output'
run: 'echo ${{ steps.deploy.outputs.url }}'
tags: ghcr.io/${{ github.repository }}/${{ env.SERVICE }}:${{ github.sha }}
Loading