Skip to content

Commit

Permalink
ci: backend docker image is tagged with git tag for production
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivien-marble committed Oct 19, 2023
1 parent 1ec6cab commit 64dddf6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
44 changes: 26 additions & 18 deletions .github/workflows/build_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
type: string
description: 'Github environment to use'
required: true
version:
type: string
description: 'version to deploy'
required: true
secrets:
GCP_SA_KEY:
required: true
Expand All @@ -20,11 +24,30 @@ jobs:
actions: read
environment: ${{ inputs.environment }}
env:
TAG: europe-west1-docker.pkg.dev/marble-infra/marble/marble-frontend:latest
IMAGE: europe-west1-docker.pkg.dev/marble-infra/marble/marble-frontend:${{ inputs.version }}
SERVICE_ACCOUNT: marble-frontend-cloud-run@${{ vars.GCP_PROJECT_ID }}.iam.gserviceaccount.com
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# source: https://github.com/docker/login-action#google-artifact-registry-gar
- name: Login to Google Artifact Registry
uses: docker/login-action@v3
with:
registry: europe-west1-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCP_SA_KEY }}

# source: https://github.com/docker/build-push-action
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
target: app-builder
tags: ${{ env.IMAGE }}

- name: Auth
uses: 'google-github-actions/auth@v1'
Expand All @@ -36,24 +59,9 @@ jobs:
with:
install_components: beta

- name: Configure Docker
run: |
gcloud auth configure-docker europe-west1-docker.pkg.dev
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
target: app-builder
tags: ${{ env.TAG }}

- name: Deploy server
run: |
gcloud run deploy marble-frontend \
--quiet \
--region="europe-west1" \
--image="${{ env.TAG }}"
--image="${{ env.IMAGE }}"
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
contents: read
actions: read
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ jobs:
uses: ./.github/workflows/build_and_deploy.yaml
with:
environment: 'staging'
version: latest
secrets:
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY_STAGING }}
1 change: 1 addition & 0 deletions .github/workflows/tags_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ jobs:
uses: ./.github/workflows/build_and_deploy.yaml
with:
environment: 'production'
version: ${{ github.ref_name }}
secrets:
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY_PRODUCTION }}

0 comments on commit 64dddf6

Please sign in to comment.