Skip to content

Commit 6873964

Browse files
committed
UPD:cd workflow with variable names
1 parent 36b8950 commit 6873964

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

.github/workflows/cd-workflow.yaml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
21
name: Deploy backstage
2+
33
on:
4-
workflow_run:
5-
workflows:
6-
- CI Workflow
7-
types:
8-
- completed
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
910

1011
jobs:
1112
create-and-push-image:
@@ -21,27 +22,32 @@ jobs:
2122
steps:
2223
- name: Checkout
2324
uses: actions/checkout@v4
25+
2426
- id: 'setup-qemu'
2527
name: Set up QEMU
2628
uses: docker/setup-qemu-action@v3
29+
2730
- id: 'docker-buildx-setup'
2831
name: Set up Docker Buildx
2932
uses: docker/setup-buildx-action@v3
33+
3034
- name: 'Authenticate to Google Cloud'
3135
id: 'auth'
3236
uses: 'google-github-actions/auth@v2'
3337
with:
3438
create_credentials_file: true
3539
token_format: "access_token"
3640
workload_identity_provider: 'projects/1006240973223/locations/global/workloadIdentityPools/deploy-backstage/providers/github-actions'
37-
service_account: '[email protected]'
41+
service_account: ${{ secrets.GCP_DEPLOY_SA }}
42+
3843
- name: "Login to GAR"
3944
id: 'login-gar'
4045
uses: docker/login-action@v3
4146
with:
42-
registry: europe-west10-docker.pkg.dev/code-idp/backstage-deploy
47+
registry: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_GAR_REPO }}
4348
username: oauth2accesstoken
4449
password: ${{ steps.auth.outputs.access_token }}
50+
4551
- id: 'build-and-push'
4652
name: 'Build and Push docker Image'
4753
uses: docker/build-push-action@v5
@@ -50,35 +56,41 @@ jobs:
5056
context: .
5157
file: ./Dockerfile
5258
platforms: linux/amd64
53-
tags: europe-west10-docker.pkg.dev/code-idp/backstage-deploy/backstage-image:${{ github.sha }}
59+
tags: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_GAR_REPO }}/backstage-image:${{ github.sha }}
5460
build-args: |
5561
APP_ENV=docker
62+
63+
5664
deploy-image:
5765
permissions:
5866
id-token: write
5967
contents: read
68+
6069
name: "Deploy image on cloud run"
6170
runs-on: ubuntu-latest
6271
defaults:
6372
run:
6473
shell: bash
6574
needs: create-and-push-image
75+
6676
steps:
6777
- name: Checkout
6878
uses: actions/checkout@v4
79+
6980
- id: 'auth'
7081
name: 'Authenticate to Google Cloud'
7182
uses: 'google-github-actions/auth@v2'
7283
with:
7384
create_credentials_file: true
7485
workload_identity_provider: 'projects/1006240973223/locations/global/workloadIdentityPools/deploy-backstage/providers/github-actions'
75-
service_account: '[email protected]'
86+
service_account: ${{ secrets.GCP_DEPLOY_SA }}
87+
7688
- id: 'deploy'
7789
uses: 'google-github-actions/deploy-cloudrun@v2'
7890
with:
79-
service: 'backstage-deployment'
80-
image: 'europe-west10-docker.pkg.dev/code-idp/backstage-deploy/backstage-image:${{ github.sha }}'
81-
region: europe-west1
91+
service: ${{ secrets.GCP_CLOUD_RUN_SERVICE }}
92+
image: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_GAR_REPO }}/backstage-image:${{ github.sha }}
93+
region: ${{ secrets.GCP_REGION }}
8294
flags: '--port=7007 --add-cloudsql-instances=code-idp:europe-west10:backstage-pg'
8395
env_vars: |
8496
POSTGRES_HOST=/cloudsql/code-idp:europe-west10:backstage-pg
@@ -90,6 +102,6 @@ jobs:
90102
GITHUB_TOKEN=github_token:latest
91103
GOOGLE_CLIENT_ID=google_client_id:latest
92104
GOOGLE_CLIENT_SECRET=google_client_secret:latest
93-
GITHUB_CLIENT_SECRET=github_client_secret:latest
94-
GITHUB_CLIENT_ID=github_client_id:latest
105+
PROD_GITHUB_CLIENT_SECRET=github_client_secret:latest
106+
PROD_GITHUB_CLIENT_ID=github_client_id:latest
95107

0 commit comments

Comments
 (0)