Skip to content

Move back to artefact registry #7

Move back to artefact registry

Move back to artefact registry #7

Workflow file for this run

name: Deploy to Google Cloud Run
on:
push:
branches:
- main
- redeploy-action
workflow_dispatch:
env:
REGISTRY: ghcr.io
GCP_PROJECT: htan-dcc
CONTAINER_NAME: data-release-validatio
jobs:
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout GitHub Action
uses: actions/checkout@v3
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Configure Docker to use Artifact Registry
run: gcloud auth configure-docker ${{ env.REGISTRY }}
- name: Extract Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.GCP_PROJECT }}/${{ env.CONTAINER_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=sha
latest
- name: Build and push to Artifact Registry
uses: docker/build-push-action@v4
with:
context: ./src
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
deploy-cloud-run:
runs-on: ubuntu-latest
needs: build-container
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: htan-dcc
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.7.0
- name: Terraform Init
run: terraform init
- name: Terraform Plan
run: terraform plan -target=google_cloud_run_v2_job.default -target=google_cloud_scheduler_job.job
- name: Terraform Apply
run: terraform apply -target=google_cloud_run_v2_job.default -target=google_cloud_scheduler_job.job -auto-approve