Skip to content

Commit 0e1cc68

Browse files
authored
GH actions use workload identity (#416)
1 parent e751211 commit 0e1cc68

File tree

1 file changed

+22
-29
lines changed

1 file changed

+22
-29
lines changed

.github/workflows/docker-build-on-tag.yml

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,25 @@ jobs:
1010

1111
runs-on: ubuntu-latest
1212

13+
permissions:
14+
contents: 'read'
15+
id-token: 'write'
16+
1317
steps:
14-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
19+
20+
- uses: 'google-github-actions/auth@v2'
21+
with:
22+
project_id: 'genuine-flight-317411'
23+
workload_identity_provider: 'projects/429189597230/locations/global/workloadIdentityPools/github/providers/robusta-repos'
24+
25+
- name: Set up gcloud CLI
26+
uses: google-github-actions/setup-gcloud@v2
27+
with:
28+
project_id: genuine-flight-317411
29+
30+
- name: Configure Docker Registry
31+
run: gcloud auth configure-docker us-central1-docker.pkg.dev
1532

1633
- name: Login to Docker Hub
1734
uses: docker/login-action@v1
@@ -28,32 +45,8 @@ jobs:
2845
context: .
2946
platforms: linux/arm64,linux/amd64
3047
push: true
31-
tags: robustadev/krr:${{ github.ref_name }}
48+
tags: |
49+
robustadev/krr:${{ github.ref_name }}
50+
us-central1-docker.pkg.dev/genuine-flight-317411/devel/krr:${{ github.ref_name }}
3251
build-args: |
33-
BUILDKIT_INLINE_CACHE=1
34-
35-
- name: Set up gcloud CLI
36-
uses: google-github-actions/[email protected]
37-
with:
38-
service_account_key: ${{ secrets.GCP_SA_KEY }}
39-
project_id: genuine-flight-317411
40-
export_default_credentials: true
41-
42-
# Configure Docker to use the gcloud command-line tool as a credential helper for authentication
43-
- name: Configure Docker
44-
run: |-
45-
gcloud auth configure-docker us-central1-docker.pkg.dev
46-
47-
- name: Verify gcloud configuration
48-
run: |-
49-
gcloud config get-value project
50-
51-
- name: Release Docker to old repo
52-
run: |-
53-
docker buildx build \
54-
--build-arg BUILDKIT_INLINE_CACHE=1 \
55-
--platform linux/arm64,linux/amd64 \
56-
--cache-from robustadev/krr:${{ github.ref_name }} \
57-
--tag us-central1-docker.pkg.dev/genuine-flight-317411/devel/krr:${{ github.ref_name }} \
58-
--push \
59-
.
52+
BUILDKIT_INLINE_CACHE=1

0 commit comments

Comments
 (0)