|
1 | | -name: Build and deploy to Google Cloud Run |
| 1 | +name: deploy |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | | - - master |
| 6 | + - main |
| 7 | + |
| 8 | + workflow_dispatch: |
7 | 9 |
|
8 | 10 | # Environment variables available to all jobs and steps in this workflow |
| 11 | +# NOTE: these aren't really secret, but there aren't non-secret settings |
9 | 12 | env: |
10 | | - PROJECT_ID: ${{ secrets.RUN_PROJECT }} |
| 13 | + RUN_PROJECT: ${{ secrets.RUN_PROJECT }} |
11 | 14 | RUN_REGION: ${{ secrets.RUN_REGION }} |
12 | | - SERVICE_NAME: ${{ secrets.RUN_SERVICE }} |
| 15 | + RUN_SERVICE: ${{ secrets.RUN_SERVICE }} |
13 | 16 |
|
14 | 17 | jobs: |
15 | | - setup-build-deploy: |
16 | | - name: Setup, Build, and Deploy |
| 18 | + deploy: |
| 19 | + name: Deploy to CloudRun |
17 | 20 | runs-on: ubuntu-latest |
18 | 21 |
|
19 | 22 | steps: |
20 | 23 | - name: Checkout |
21 | | - uses: actions/checkout@v1 |
| 24 | + uses: actions/checkout@v4 |
22 | 25 |
|
23 | | - # Setup gcloud CLI |
24 | | - - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master |
| 26 | + - name: gcloud auth |
| 27 | + id: 'auth' |
| 28 | + uses: 'google-github-actions/auth@v2' |
25 | 29 | with: |
26 | | - version: '275.0.0' |
27 | | - service_account_email: ${{ secrets. GCP_SA_EMAIL }} |
28 | | - service_account_key: ${{ secrets. GCP_SA_KEY }} |
| 30 | + credentials_json: '${{ secrets.GCP_SA_KEY }}' |
29 | 31 |
|
30 | | - # Configure gcloud CLI |
31 | | - - name: gcloud Set up |
32 | | - run: | |
33 | | - gcloud config set project $PROJECT_ID |
| 32 | + # Setup gcloud CLI |
| 33 | + - name: gcloud setup |
| 34 | + uses: google-github-actions/setup-gcloud@v2 |
| 35 | + |
| 36 | + - name: gcloud docker-auth |
| 37 | + run: gcloud auth configure-docker |
34 | 38 |
|
35 | 39 | # Build and push image to Google Container Registry |
36 | 40 | - name: Build |
37 | 41 | run: | |
38 | 42 | docker build \ |
39 | 43 | --build-arg COMMIT=${GITHUB_SHA:0:7} \ |
40 | 44 | --build-arg LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ) \ |
41 | | - --tag gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA . |
| 45 | + --tag gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \ |
| 46 | + . |
42 | 47 |
|
43 | 48 | - name: GCloud auth to docker |
44 | 49 | run: | |
45 | 50 | gcloud auth configure-docker |
46 | 51 |
|
47 | 52 | - name: Push to registry |
48 | 53 | run: | |
49 | | - docker push gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA |
| 54 | + docker push gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA |
50 | 55 |
|
51 | 56 | # Deploy image to Cloud Run |
52 | 57 | - name: Deploy |
53 | 58 | run: | |
54 | | - gcloud run deploy $SERVICE_NAME \ |
| 59 | + gcloud run deploy ${RUN_SERVICE} \ |
55 | 60 | --allow-unauthenticated \ |
56 | | - --image gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA \ |
| 61 | + --image gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \ |
57 | 62 | --platform managed \ |
58 | | - --project ${PROJECT_ID} \ |
59 | | - --region $RUN_REGION |
| 63 | + --project ${RUN_PROJECT} \ |
| 64 | + --region ${RUN_REGION} |
0 commit comments