From 467bb7c84b164339a7756b56280bd2eddd729b75 Mon Sep 17 00:00:00 2001 From: Johnson Liang Date: Mon, 2 Oct 2023 21:58:04 +0800 Subject: [PATCH] ci: cloud run auto deploy --- .github/workflows/build-and-push.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 2228c06b..9380654d 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -64,3 +64,22 @@ jobs: - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} + + deploy: + needs: build-and-push + runs-on: ubuntu-latest + strategy: + matrix: + locale: ['en', 'tw', 'ja'] + env: + RELEASE_TAG: ${{ startsWith(github.ref, 'refs/tags/release') && 'latest' || 'dev' }} + CLOUDRUN_SERVICE_NAME: ${{ startsWith(github.ref, 'refs/tags/release') && 'site' || 'site-staging' }} + steps: + - uses: 'google-github-actions/auth@v1' + with: + workload_identity_provider: ${{ secrets.GC_WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.GC_SERVICE_ACCOUNT }} + - uses: 'google-github-actions/deploy-cloudrun@v1' + with: + service: ${{ env.CLOUDRUN_SERVICE_NAME }}-${{matrix.locale}} + image: cofacts/rumors-site:${{ env.RELEASE_TAG }}-${{ matrix.locale }}