Skip to content

放慢說話速度

放慢說話速度 #13

name: Build and Deploy to GCP
on:
push:
branches:
- main
jobs:
Deploy:
runs-on: ubuntu-latest
name: Build and Deploy to GCP
steps:
- name: Set secret env
run: |
echo "SECRET_ENV=${GITHUB_REF_NAME^^}" >> "$GITHUB_ENV"
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GAR
uses: docker/login-action@v2
with:
registry: '${{ secrets.GCP_REGION }}-docker.pkg.dev'
username: _json_key
password: ${{ secrets.GCP_SA_KEY }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets[format('RUN_IMAGE_TAG_{0}', env.SECRET_ENV)] }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: GCP auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Deploy Cloud Run
uses: google-github-actions/deploy-cloudrun@v0
with:
service: ${{ secrets[format('RUN_SERVICE_NAME_{0}', env.SECRET_ENV)] }}
image: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets[format('RUN_IMAGE_TAG_{0}', env.SECRET_ENV)] }}
region: ${{ secrets.GCP_REGION }}