Skip to content

Commit b12cb2b

Browse files
committed
Add workflow for building and pushing Docker image
1 parent 588d2d7 commit b12cb2b

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Docker Publish
2+
3+
on:
4+
push:
5+
branches: [ github-actions ]
6+
tags: [ 'v*' ]
7+
8+
env:
9+
GCP_ARTIFACT_HOST: ${{ vars.SHARED_WIF_LOCATON }}-docker.pkg.dev
10+
GCP_REGISTRY: ${{ vars.SHARED_WIF_LOCATON }}-docker.pkg.dev/${{ vars.SHARED_WIF_PROJECT }}/${{ vars.SHARED_WIF_REPO }}
11+
IMAGE_NAME: portal-public-api-docs
12+
13+
jobs:
14+
docker-publish:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: write
18+
contents: read
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Google Auth
24+
id: 'auth'
25+
uses: 'google-github-actions/auth@v2'
26+
with:
27+
workload_identity_provider: "${{ vars.SHARED_WIF_PROVIDER }}"
28+
service_account: "${{ vars.SHARED_WIF_SERVICE_ACCOUNT }}"
29+
token_format: 'access_token'
30+
31+
- name: Docker Login
32+
uses: 'docker/login-action@v3'
33+
with:
34+
registry: ${{ env.GCP_ARTIFACT_HOST }}
35+
username: 'oauth2accesstoken'
36+
password: ${{ steps.auth.outputs.access_token }}
37+
38+
- name: Docker Buildx Setup
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Docker Metadata
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.GCP_REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=raw,value=v-latest
48+
type=ref,event=tag
49+
type=sha
50+
flavor: |
51+
latest=false
52+
53+
- name: Docker Build
54+
uses: docker/bake-action@v6
55+
with:
56+
source: .
57+
files: |
58+
./docker-bake.hcl
59+
${{ steps.meta.outputs.bake-file }}
60+
push: false

0 commit comments

Comments
 (0)