-
Notifications
You must be signed in to change notification settings - Fork 3
67 lines (57 loc) · 2.16 KB
/
build-and-deploy-backend.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Build Image and Deploy to Cloud Run
on:
push:
branches:
- backend
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
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
if: contains(github.event.head_commit.message, '-deploy')
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 }}"'