-
Notifications
You must be signed in to change notification settings - Fork 78
49 lines (44 loc) · 1.59 KB
/
build.yml
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
name: build
on:
push:
branches:
- master
- deploy-*
tags:
- v*.*.*
jobs:
cloudbuild:
runs-on: ubuntu-latest
environment: prod
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
- name: Check release version
id: check-tag
run: |
echo "version=$(echo ${{ github.event.ref }} | cut -d / -f 3 | cut -c2-)" >> $GITHUB_OUTPUT
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "match=true" >> $GITHUB_OUTPUT
fi
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
export_default_credentials: true
- name: Build Docker container and publish on GCR
run: make cloudbuild || true
env:
GCR_PROJECT_ID: ${{ secrets.GCR_PROJECT_ID }}
CLOUDBUILD_PROJECT_ID: ${{ secrets.CLOUDBUILD_PROJECT_ID }}
VERSION: ${{ steps.check-tag.outputs.match == 'true' && steps.check-tag.outputs.version || github.event.pull_request.head.sha || github.sha }}
- name: Build Docker container and publish on GCR [latest]
run: make cloudbuild || true
if: ${{ steps.check-tag.outputs.match == 'true' }}
env:
GCR_PROJECT_ID: ${{ secrets.GCR_PROJECT_ID }}
CLOUDBUILD_PROJECT_ID: ${{ secrets.CLOUDBUILD_PROJECT_ID }}
VERSION: latest