-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (68 loc) · 2.2 KB
/
build-and-push.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
68
69
70
71
72
73
74
75
76
77
name: Build and Deploy Docker Image
permissions:
contents: read
id-token: write
on:
push:
branches:
- develop
- main
paths:
- 'src/**'
- 'server.js'
- 'index.html'
- 'tsconfig.json'
- 'tsconfig.node.json'
- 'vite.config.ts'
- 'package.json'
- 'package-lock.json'
- 'Dockerfile'
release:
types: [published]
workflow_dispatch:
env:
REGISTRY: europe-north1-docker.pkg.dev/${{ secrets.GAR_PROJECT_ID }}/dapla-stat-docker
IMAGE: dapla-ctrl
TAG: ${{ github.ref_name }}-${{ github.sha }}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/[email protected]'
with:
workload_identity_provider: 'projects/${{ secrets.GAR_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/gh-actions/providers/gh-actions'
service_account: 'gh-actions-dapla-stat@${{ secrets.GAR_PROJECT_ID }}.iam.gserviceaccount.com'
token_format: 'access_token'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
- name: Docker meta
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr,suffix=-${{ github.event.pull_request.head.sha }}
type=raw,value={{branch}}-{{sha}}-{{date 'YYYYMMDDHHmmss'}},enable={{is_default_branch}}
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=raw,value=${{ env.TAG }}, enable=true
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.metadata.outputs.tags }}