Skip to content

update GitHub Actions Workflows #5

update GitHub Actions Workflows

update GitHub Actions Workflows #5

Workflow file for this run

name: CI and CD Pipeline to Cloud Run
on:
push:
branches:
- main
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set environment variables
run: |
echo "IMAGE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Auth Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Setup Secret for Pulling Image
run: |
echo -n '{"auths":{"https://ghcr.io/v1/":{"username":"${{ secrets.REGISTRY_USER }}","password":"${{ secrets.REGISTRY_PASSWORD }}"}}}' > /tmp/.dockerconfigjson
gcloud secrets create cloud-run-secret --data-file=/tmp/.dockerconfigjson --replication-policy=automatic || echo "Secret already exists"
gcloud secrets versions add cloud-run-secret --data-file=/tmp/.dockerconfigjson
- name: Build and push Docker image Backend
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
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.front
push: true
tags: ghcr.io/${{ github.repository }}/cloud-run-front:${{ env.IMAGE_VERSION }}