|
1 | | -name: Deploy Backstage |
2 | | - |
| 1 | +name: Deploy backstage |
3 | 2 | on: |
4 | | - workflow_run: |
5 | | - workflows: ["CI Workflow"] |
6 | | - types: |
7 | | - - completed |
| 3 | + workflow_dispatch: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
8 | 7 |
|
9 | 8 | jobs: |
10 | 9 | create-and-push-image: |
11 | 10 | permissions: |
12 | 11 | 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" |
16 | 14 | runs-on: ubuntu-latest |
17 | 15 | defaults: |
18 | 16 | run: |
19 | 17 | shell: bash |
20 | 18 |
|
21 | 19 | steps: |
22 | | - - name: Checkout Repository |
| 20 | + - name: Checkout |
23 | 21 | uses: actions/checkout@v4 |
24 | | - |
25 | | - - name: Set up QEMU |
26 | | - id: setup-qemu |
| 22 | + - id: 'setup-qemu' |
| 23 | + name: Set up QEMU |
27 | 24 | 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 |
31 | 27 | 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' |
36 | 31 | with: |
37 | | - #create_credentials_file: true |
| 32 | + create_credentials_file: true |
38 | 33 | 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: 'deploy-backstage@code-idp.iam.gserviceaccount.com' |
| 36 | + - id: 'login-gar' |
| 37 | + name: "Login to GAR" |
50 | 38 | uses: docker/login-action@v3 |
51 | 39 | with: |
52 | | - registry: ${{ secrets.GCP_REGION }}-docker.pkg.dev |
| 40 | + registry: europe-west10-docker.pkg.dev/code-idp/backstage-deploy |
53 | 41 | username: oauth2accesstoken |
54 | 42 | 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' |
63 | 45 | uses: docker/build-push-action@v5 |
64 | 46 | with: |
65 | 47 | push: true |
66 | 48 | context: . |
67 | 49 | file: ./Dockerfile |
68 | 50 | 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 }} |
70 | 52 | build-args: | |
71 | 53 | APP_ENV=docker |
72 | | -
|
73 | 54 | deploy-image: |
74 | 55 | permissions: |
75 | 56 | 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" |
79 | 59 | runs-on: ubuntu-latest |
80 | | - needs: create-and-push-image |
81 | 60 | defaults: |
82 | 61 | run: |
83 | 62 | shell: bash |
84 | | - |
| 63 | + needs: create-and-push-image |
85 | 64 | steps: |
86 | | - - name: Checkout Repository |
| 65 | + - name: Checkout |
87 | 66 | 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' |
92 | 70 | with: |
93 | 71 | 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 |
106 | 72 | 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: > |
112 | | - --allow-unauthenticated |
| 73 | + service: 'backstage-deployment' |
| 74 | + image: 'europe-west10-docker.pkg.dev/code-idp/backstage-deploy/backstage-image:${{ github.sha }}' |
| 75 | + region: europe-west10 |
| 76 | + flags: | |
113 | 77 | --port=7007 |
114 | | - --add-cloudsql-instances=${{ secrets.GCP_SQL_CONNECTION_NAME }} |
115 | | - env_vars: | |
116 | | - POSTGRES_HOST=${{ secrets.POSTGRES_HOST }} |
117 | | - POSTGRES_PORT=5432 |
118 | | - BASE_URL=https://backstage.foundations-software-engineering.com |
0 commit comments