-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (66 loc) · 2.4 KB
/
build-and-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Docker build & deploy
on:
push:
branches:
- master
env:
GHCR_IMAGE_TAG: ghcr.io/${{ github.repository_owner }}/se2gha
GCP_PROJECT_ID: vvakame-playground
GCP_IMAGE_TAG: gcr.io/vvakame-playground/se2gha:commit_${{ github.sha }}
GCP_REGION: us-central1
SERVICE_NAME: se2gha
jobs:
deploy:
name: Docker build & deploy
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- run: |
docker build . --tag $GHCR_IMAGE_TAG
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
# se2gha-ghcr-write
password: ${{ secrets.DOCKER_CR_PAT }}
- name: Push tagged image to GitHub Container Registry
run: |
docker push $GHCR_IMAGE_TAG
- uses: google-github-actions/setup-gcloud@v1
with:
version: "417.0.0"
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: projects/381521917100/locations/global/workloadIdentityPools/github-actions/providers/gha-provider
service_account: [email protected]
access_token_lifetime: 1200s
- name: Push tagged image to Google Container Registry
run: |
gcloud auth configure-docker
docker tag $GHCR_IMAGE_TAG $GCP_IMAGE_TAG
docker push $GCP_IMAGE_TAG
- name: Deploy
run: |-
gcloud run deploy "${SERVICE_NAME}" \
--project "${GCP_PROJECT_ID}" \
--region "${GCP_REGION}" \
--image "${{ env.GCP_IMAGE_TAG }}" \
--platform managed \
--allow-unauthenticated \
--no-traffic \
--set-env-vars "GOOGLE_CLOUD_PROJECT=${GCP_PROJECT_ID}" \
--set-env-vars "SLACK_ACCESS_TOKEN=${{ secrets.SLACK_ACCESS_TOKEN }}" \
--set-env-vars "SLACK_SIGNING_SECRET=${{ secrets.SLACK_SIGNING_SECRET }}" \
--set-env-vars "GHA_REPO_TOKEN=${{ secrets.GHA_REPO_TOKEN }}" \
--set-env-vars "GHA_REPOS=${{ secrets.GHA_REPOS }}" \
--quiet
- name: Release
run: |-
gcloud run services update-traffic "${SERVICE_NAME}" \
--to-latest \
--region "${GCP_REGION}" \
--platform managed \
--quiet