Skip to content

fix(ci): get only one image tag from metadata action #4

fix(ci): get only one image tag from metadata action

fix(ci): get only one image tag from metadata action #4

Workflow file for this run

name: Build and Deploy to Cloud Run
on:
push:
branches:
- master
tags:
- "v*"
env:
IMAGE_NAME: tutortoise-backend
PROJECT_ID: ${{ secrets.PROJECT_ID }}
REGION: asia-southeast2
AR_URL: ${{ secrets.AR_URL }}
SERVICE_ACCOUNT: ${{ secrets.SERVICE_ACCOUNT }}
WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
jobs:
deploy:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
token_format: access_token
project_id: ${{ env.PROJECT_ID }}
service_account: ${{ env.SERVICE_ACCOUNT }}
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: '${{ env.REGION }}-docker.pkg.dev'
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Extract metadata for docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.AR_URL }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: 'Deploy to Cloud Run'
uses: 'google-github-actions/deploy-cloudrun@v2'
with:
service: '${{ env.IMAGE_NAME }}'
region: '${{ env.REGION }}'
image: ${{ steps.meta.outputs.tags }}
# If required, use the Cloud Run URL output in later steps
- name: 'Show output'
run: |2-
echo ${{ steps.deploy.outputs.url }}