Skip to content

Commit

Permalink
Backend-gh-actions-deploy#45
Browse files Browse the repository at this point in the history
  • Loading branch information
krugergui authored Oct 22, 2023
1 parent a40dd18 commit d04ffbe
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/build-and-deploy-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release
on:
push:
branches:
- backend

env:
REPOSITORY_REGION: europe-west10
PROJECT_ID: dockerruntest
REPO_NAME: quickstart-docker-repo
IMAGE_NAME: django-backend-shift-enter
PROJECT_USER: [email protected]

jobs:
docker-release:
name: Tagged Docker release to Google Artifact Registry
runs-on: ubuntu-latest

steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4

- name: Login to Artifact Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REPOSITORY_REGION }}-docker.pkg.dev
username: _json_key
password: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_GUIL }}

- name: Get tag
id: get-tag
run: echo "{short_ref}={GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Create .env
env:
ENV_FILE_BACKEND: ${{ secrets.ENV_FILE_BACKEND }}
run: echo $ENV_FILE_BACKEND | base64 --decode > ./backend/.env

- id: docker-push-tagged
name: Tag Docker image and push to Google Artifact Registry
uses: docker/[email protected]
with:
push: true
tags: |
${{ env.REPOSITORY_REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ github.event.head_commit.message }}
context: ./backend

- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_GUIL }}'

- id: 'deploy'
name: Deploy to GC RUN
uses: 'google-github-actions/deploy-cloudrun@v1'
with:
service: ${{ env.IMAGE_NAME }}
image: ${{ env.REPOSITORY_REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ github.event.head_commit.message }}
region: ${{ env.REPOSITORY_REGION }}

- name: 'Use output'
run: 'curl "${{ steps.deploy.outputs.url }}"'
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ celerybeat.pid
*.sage.py

# Environments
.env
.venv
env/
venv/
Expand Down

0 comments on commit d04ffbe

Please sign in to comment.