-
Notifications
You must be signed in to change notification settings - Fork 77
72 lines (70 loc) · 2.38 KB
/
build-images.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: build-images
on:
push:
branches:
- 'master'
tags:
- 'v*'
paths-ignore:
- 'README.md'
pull_request:
branches:
- 'master'
jobs:
build-and-push-image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./cli/Dockerfile
context: .
image: europe-docker.pkg.dev/instant-bqml-demo-environment/crmint/cli
- dockerfile: ./frontend/Dockerfile
context: ./frontend
image: europe-docker.pkg.dev/instant-bqml-demo-environment/crmint/frontend
- dockerfile: ./backend/controller.Dockerfile
context: ./backend
image: europe-docker.pkg.dev/instant-bqml-demo-environment/crmint/controller
- dockerfile: ./backend/jobs.Dockerfile
context: ./backend
image: europe-docker.pkg.dev/instant-bqml-demo-environment/crmint/jobs
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- id: auth
name: Authenticate to Google Cloud
if: github.event_name != 'pull_request'
uses: google-github-actions/auth@v1
with:
token_format: access_token
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.CLOUD_BUILD_RUNNER_SA }}
- name: Login to Google Artifact Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: europe-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ matrix.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}