-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: try deploy dl-queue on Cloud Run
- Loading branch information
1 parent
e806bc2
commit 0a538a3
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|