Skip to content

Commit 64546fe

Browse files
authored
feat: add reusable workflow for pushing images to GAR (#15)
* feat: add reusable workflow for pushing images to GAR * chore: update Google Cloud authentication action to v3
1 parent bdf7009 commit 64546fe

4 files changed

Lines changed: 69 additions & 27 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Reusable Workflow For Build-Push to Google Artifact Registry
2+
on:
3+
workflow_call:
4+
inputs:
5+
gar-region:
6+
type: string
7+
default: "asia-northeast3"
8+
gar-project-id:
9+
required: true
10+
type: string
11+
gar-repository:
12+
required: true
13+
type: string
14+
service-name:
15+
required: true
16+
type: string
17+
image-tag:
18+
required: true
19+
type: string
20+
workload-identity-provider:
21+
required: true
22+
type: string
23+
service-account:
24+
required: true
25+
type: string
26+
target:
27+
required: false
28+
type: string
29+
30+
permissions:
31+
contents: read
32+
id-token: write
33+
34+
jobs:
35+
build-push:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Authenticate to Google Cloud
41+
id: auth
42+
uses: google-github-actions/auth@v3
43+
with:
44+
workload_identity_provider: ${{ inputs.workload-identity-provider }}
45+
service_account: ${{ inputs.service-account }}
46+
token_format: "access_token"
47+
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@v2
50+
51+
- name: Log in to Google Artifact Registry
52+
uses: docker/login-action@v3
53+
with:
54+
registry: ${{ inputs.gar-region }}-docker.pkg.dev
55+
username: oauth2accesstoken
56+
password: ${{ steps.auth.outputs.access_token }}
57+
58+
- name: Build and push
59+
uses: docker/build-push-action@v3
60+
with:
61+
context: .
62+
push: true
63+
tags: ${{ inputs.gar-region }}-docker.pkg.dev/${{ inputs.gar-project-id }}/${{ inputs.gar-repository }}/${{ inputs.service-name }}:${{ inputs.image-tag }}
64+
target: ${{ inputs.target || '' }}
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max

.github/workflows/notify-teams.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/prod-image-tag.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
RELEASE_TAG: ${{ steps.release-tag.outputs.RELEASE_TAG }}
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- id: release-tag
1818
run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

.github/workflows/staging-image-tag.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
IMAGE_TAG: ${{ steps.IMAGE_TAG.outputs.IMAGE_TAG }}
1414

1515
steps:
16-
- uses: actions/checkout@v3
17-
- uses: benjlevesque/short-sha@v1.2
16+
- uses: actions/checkout@v4
17+
- uses: benjlevesque/short-sha@v2.2
1818
id: short-sha
1919
- id: IMAGE_TAG
2020
run: echo "IMAGE_TAG=staging-${{ steps.short-sha.outputs.sha }}" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)