Skip to content

Commit d5bb3f1

Browse files
authored
UPD: Update cd-workflow.yaml
1 parent d059a10 commit d5bb3f1

File tree

1 file changed

+42
-74
lines changed

1 file changed

+42
-74
lines changed

.github/workflows/cd-workflow.yaml

Lines changed: 42 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,94 @@
1-
name: Deploy Backstage
2-
1+
name: Deploy backstage
32
on:
4-
workflow_run:
5-
workflows: ["CI Workflow"]
6-
types:
7-
- completed
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
87

98
jobs:
109
create-and-push-image:
1110
permissions:
1211
id-token: write
13-
contents: read # Remove if not required
14-
15-
name: "Create and Push Docker Image to GAR"
12+
contents: read
13+
name: "Create and push the Docker image to GAR"
1614
runs-on: ubuntu-latest
1715
defaults:
1816
run:
1917
shell: bash
2018

2119
steps:
22-
- name: Checkout Repository
20+
- name: Checkout
2321
uses: actions/checkout@v4
24-
25-
- name: Set up QEMU
26-
id: setup-qemu
22+
- id: 'setup-qemu'
23+
name: Set up QEMU
2724
uses: docker/setup-qemu-action@v3
28-
29-
- name: Set up Docker Buildx
30-
id: docker-buildx-setup
25+
- id: 'docker-buildx-setup'
26+
name: Set up Docker Buildx
3127
uses: docker/setup-buildx-action@v3
32-
33-
- name: Authenticate to Google Cloud
34-
id: auth
35-
uses: google-github-actions/auth@v1
28+
- id: 'auth'
29+
name: 'Authenticate to Google Cloud'
30+
uses: 'google-github-actions/auth@v2'
3631
with:
37-
#create_credentials_file: true
32+
create_credentials_file: true
3833
token_format: access_token
39-
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
40-
service_account: ${{ secrets.GCP_DEPLOY_SA }}
41-
42-
- name: Set up GCP SDK
43-
uses: google-github-actions/setup-gcloud@v1
44-
with:
45-
version: "latest"
46-
project_id: ${{ secrets.GCP_PROJECT_ID }}
47-
48-
- name: Login to GAR
49-
id: login-gar
34+
workload_identity_provider: 'projects/1006240973223/locations/global/workloadIdentityPools/deploy-backstage/providers/github-actions'
35+
service_account: '[email protected]'
36+
- id: 'login-gar'
37+
name: "Login to GAR"
5038
uses: docker/login-action@v3
5139
with:
52-
registry: ${{ secrets.GCP_REGION }}-docker.pkg.dev
40+
registry: europe-west10-docker.pkg.dev/code-idp/backstage-deploy
5341
username: oauth2accesstoken
5442
password: ${{ steps.auth.outputs.access_token }}
55-
56-
- name: Configure Docker for Artifact Registry
57-
run: |
58-
gcloud auth configure-docker \
59-
${{ secrets.GCP_REGION }}-docker.pkg.dev
60-
61-
- name: Build and Push Docker Image
62-
id: build-and-push
43+
- id: 'build-and-push'
44+
name: 'Build and Push docker Image'
6345
uses: docker/build-push-action@v5
6446
with:
6547
push: true
6648
context: .
6749
file: ./Dockerfile
6850
platforms: linux/amd64
69-
tags: ${{ secrets.GCP_GAR_REPO }}/backstage-image:${{ github.sha }}
51+
tags: europe-west10-docker.pkg.dev/code-idp/backstage-deploy/backstage-image:${{ github.sha }}
7052
build-args: |
7153
APP_ENV=docker
72-
7354
deploy-image:
7455
permissions:
7556
id-token: write
76-
contents: read # Remove if not required
77-
78-
name: "Deploy Image on Cloud Run"
57+
contents: read
58+
name: "Deploy image on cloud run"
7959
runs-on: ubuntu-latest
80-
needs: create-and-push-image
8160
defaults:
8261
run:
8362
shell: bash
84-
63+
needs: create-and-push-image
8564
steps:
86-
- name: Checkout Repository
65+
- name: Checkout
8766
uses: actions/checkout@v4
88-
89-
- name: Authenticate to Google Cloud
90-
id: auth
91-
uses: google-github-actions/auth@v2
67+
- id: 'auth'
68+
name: 'Authenticate to Google Cloud'
69+
uses: 'google-github-actions/auth@v2'
9270
with:
9371
create_credentials_file: true
94-
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
95-
service_account: ${{ secrets.GCP_DEPLOY_SA }}
96-
97-
- name: Set up GCP SDK
98-
uses: google-github-actions/setup-gcloud@v1
99-
with:
100-
project_id: ${{ secrets.GCP_PROJECT_ID }}
101-
102-
103-
- name: Deploy to Cloud Run
104-
id: deploy
105-
uses: google-github-actions/deploy-cloudrun@v1
72+
workload_identity_provider: 'projects/1006240973223/locations/global/workloadIdentityPools/deploy-backstage/providers/github-actions'
73+
service_account: '[email protected]'
74+
- id: 'deploy'
75+
uses: 'google-github-actions/deploy-cloudrun@v2'
10676
with:
107-
project_id: ${{ secrets.GCP_PROJECT_ID }}
108-
service: ${{ secrets.GCP_CLOUD_RUN_SERVICE }}
109-
image: ${{ secrets.GCP_GAR_REPO }}/backstage-image:${{ github.sha }}
110-
region: ${{ secrets.GCP_REGION }}
111-
flags: '--port=7007 --add-cloudsql-instances=code-idp:europe-west10:backstage-pg'
77+
service: 'backstage-deployment'
78+
image: 'europe-west10-docker.pkg.dev/code-idp/backstage-deploy/backstage-image:${{ github.sha }}'
79+
region: europe-west1
80+
flags: '--port=7007 --allow-unanthenticated --add-cloudsql-instances=code-idp:europe-west10:backstage-pg'
11281
env_vars: |
11382
POSTGRES_HOST=/cloudsql/code-idp:europe-west10:backstage-pg
11483
POSTGRES_PORT=5432
11584
POSTGRES_USER=postgres
116-
POSTGRES_DB=postgres
11785
BASE_URL=https://backstage.foundations-software-engineering.com
118-
secrets: |
119-
POSTGRES_PASSWORD=postgres_password:latest
86+
secrets: |-
87+
POSTGRES_PASSWORD=postgres-password:latest
12088
GITHUB_TOKEN=github_token:latest
12189
GOOGLE_CLIENT_ID=google_client_id:latest
12290
GOOGLE_CLIENT_SECRET=google_client_secret:latest
91+
GITHUB_CLIENT_ID=github_client_id:latest
12392
GITHUB_CLIENT_SECRET=github_client_secret:latest
12493
GITLAB_TOKEN=gitlab_token:latest
12594
TECHDOCS_GCS_CREDENTIALS=techdocs_gcs_credentials:latest
126-

0 commit comments

Comments
 (0)