Skip to content

update GitHub Actions Workflows #21

update GitHub Actions Workflows

update GitHub Actions Workflows #21

Workflow file for this run

name: CI and CD Pipeline to Cloud Run
on:
push:
branches:
- main
- dev
jobs:
build:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- name: Checkout code
id: checkout
uses: actions/checkout@v4
- name: Set environment variables
id: set-env
run: |
echo "IMAGE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Auth Container Registry
id: container-registry-auth
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Gcloud Auth
id: gcloud-auth
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.PROJECT_ID }}
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT }}
- name: Build and push Docker image Backend
id: build-push-back
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.back
push: true
tags: ghcr.io/${{ github.repository }}/cloud-run-back:${{ env.IMAGE_VERSION }}
- name: Build and push Docker image Frontend
id: build-push-front
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.front
push: true
tags: ghcr.io/${{ github.repository }}/cloud-run-front:${{ env.IMAGE_VERSION }}
- name: Deploy to Cloud Run Backend
id: deploy-cloud-run-back
uses: google-github-actions/deploy-cloudrun@v2
with:
service: cloud-run-backend-${{ env.IMAGE_VERSION }}
image: ghcr.io/${{ github.repository }}/cloud-run-back:${{ env.IMAGE_VERSION }}
region: asia-southeast2
project_id: ${{ secrets.PROJECT_ID }}
- name: Deploy to Cloud Run Frontend
id: deploy-cloud-run-front
uses: google-github-actions/deploy-cloudrun@v2
with:
service: cloud-run-frontend-${{ env.IMAGE_VERSION }}
image: ghcr.io/${{ github.repository }}/cloud-run-front:${{ env.IMAGE_VERSION }}
region: asia-southeast2
project_id: ${{ secrets.PROJECT_ID }}