Deploy #43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | |
- name: Setup Cloud SDK | |
id: 'auth' | |
uses: google-github-actions/auth@v0 | |
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@v0 | |
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 |