-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (52 loc) · 2.04 KB
/
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
name: Deploy
on:
workflow_dispatch:
push:
tags:
- "*"
env:
PROJECT_NUMBER: ${{ secrets.GCP_PROJECT_NUMBER }}
PROJECT_ID: ${{ secrets.GCP_PROJECT }}
GCR_LOCATION: asia.gcr.io
GCR_REGION: asia-northeast1
WI_POOL_ID: ${{ secrets.WI_POOL_ID }}
WI_PROVIDER_ID: ${{ secrets.WI_PROVIDER_ID }}
WI_SERVICE_ACCOUNT: ${{ secrets.WI_SERVICE_ACCOUNT }}
LOGBOOK_ATMOS_TOKEN: ${{ secrets.LOGBOOK_ATMOS_TOKEN }}
LOGBOOK_ATMOS_API: ${{ secrets.LOGBOOK_ATMOS_API }}
SERVICE: logbook-api
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Cloud SDK
id: "auth"
uses: google-github-actions/auth@v2
with:
create_credentials_file: true
workload_identity_provider: projects/${{ env.PROJECT_NUMBER }}/locations/global/workloadIdentityPools/${{ env.WI_POOL_ID }}/providers/${{ env.WI_PROVIDER_ID }}
service_account: ${{ env.WI_SERVICE_ACCOUNT }}
- name: Activate gcloud
run: gcloud auth login --brief --cred-file="${{ steps.auth.outputs.credentials_file_path }}"
- name: Authorize Docker push
run: gcloud auth configure-docker --quiet
- name: Build Container Image
run: docker build -t ${{ env.GCR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} .
- name: Push Container Image
run: docker push ${{ env.GCR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v2
with:
image: ${{ env.GCR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}
project_id: ${{ env.PROJECT_ID }}
region: ${{ env.GCR_REGION }}
service: ${{ env.SERVICE }}
env_vars: LOGBOOK_ATMOS_TOKEN=${{ env.LOGBOOK_ATMOS_TOKEN }},LOGBOOK_ATMOS_API=${{ env.LOGBOOK_ATMOS_API }}
tag: latest
no_traffic: false