Skip to content

Commit

Permalink
build: try deploy dl-queue on Cloud Run
Browse files Browse the repository at this point in the history
  • Loading branch information
BelgianNoise committed May 24, 2024
1 parent e806bc2 commit 0a538a3
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/publish-deploy-gcp-dl-queue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: 'Build docker image, push to GCP Artifact Registry and deploy on GCP Cloud Run'

on:
push:
paths:
- dl-queue/**
branches:
- main
workflow_dispatch:

jobs:

build-push-deploy:
runs-on: ubuntu-latest
env:
IMAGE_NAME: dl-queue
PROJECT_ID: dl-utils
SA_NAME: github-actions
CLOUD_RUN_SERVICE: dl-queue
REGION: europe-west1
REGISTRY_HOSTNAME: europe-west1-docker.pkg.dev
REGISTRY_NAME: docker-images

# From docs
permissions:
contents: 'read'
id-token: 'write'

steps:

# Important to do this before GCP Auth
- name: Checkout
uses: actions/checkout@v4

- name: Authenticate GCP
uses: google-github-actions/auth@v2
with:
service_account: ${{ env.SA_NAME }}@${{ env.PROJECT_ID }}.iam.gserviceaccount.com
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: Setup GCP
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ env.PROJECT_ID }}

- name: Build the Docker image
run: docker build -t ${{ env.IMAGE_NAME }}:latest ./dl-queue

- name: Configure Docker
run: |
gcloud auth configure-docker ${{ env.REGISTRY_HOSTNAME }}
- name: Generate reuseable variable for image
run: |
echo "IMAGE_LOCATION=${{ env.REGISTRY_HOSTNAME }}/${{ env.PROJECT_ID }}/${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
- name: Push docker image to GCP Artifact Registry
run: |
docker tag ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_LOCATION }}:latest
docker push ${{ env.IMAGE_LOCATION }}:latest
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ env.CLOUD_RUN_SERVICE }}
image: ${{ env.IMAGE_LOCATION }}:latest
region: ${{ env.REGION }}
project_id: ${{ env.PROJECT_ID }}

- name: Test the deployed service
run: curl "${{ steps.deploy.outputs.url }}"
1 change: 1 addition & 0 deletions .github/workflows/publish-dl-queue.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Not really required anymore but let's just keep it in for now
name: Publish dl-queue

on:
Expand Down

0 comments on commit 0a538a3

Please sign in to comment.