Skip to content

Commit

Permalink
Update gcp auth to Workload Identity (#6223)
Browse files Browse the repository at this point in the history
## Motivation

Enhance application security by migrating from service account key-based authentication to workload identity. This aligns with best practices for cloud-based applications. [WIF](https://cloud.google.com/iam/docs/workload-identity-federation)



Co-authored-by: Matthias <[email protected]>
  • Loading branch information
andres-spacemesh and fasmat committed Aug 17, 2024
1 parent a03ea8f commit dfcb513
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
outname_sufix: "mac-arm64"
- os: windows-2022
outname_sufix: "win-amd64"
permissions:
contents: 'read'
id-token: 'write'
steps:
- shell: bash
run: echo "OUTNAME=go-spacemesh-${{ github.ref_name }}-${{ matrix.outname_sufix }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -79,7 +82,10 @@ jobs:
- name: Setup gcloud authentication
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
project_id: ${{ secrets.GCP_WI_PROJECT_ID }}
workload_identity_provider: ${{ secrets.GCP_WI_PROVIDER_SA }}
service_account: ${{ secrets.GCP_WI_SA }}
token_format: access_token
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
Expand Down Expand Up @@ -126,6 +132,9 @@ jobs:
release:
runs-on: ubuntu-22.04
needs: build-and-upload
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Download the artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -153,7 +162,10 @@ jobs:
- name: Setup gcloud authentication
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
project_id: ${{ secrets.GCP_WI_PROJECT_ID }}
workload_identity_provider: ${{ secrets.GCP_WI_PROVIDER_SA }}
service_account: ${{ secrets.GCP_WI_SA }}
token_format: access_token
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/systest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
needs:
- filter-changes
timeout-minutes: 70
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -72,8 +75,10 @@ jobs:
- name: Setup gcloud authentication
uses: google-github-actions/auth@v2
with:
# GCP_CREDENTIALS is minified JSON of service account
credentials_json: "${{ secrets.CI_GCP_CREDENTIALS }}"
project_id: ${{ secrets.GCP_WI_PROJECT_ID }}
workload_identity_provider: ${{ secrets.GCP_WI_PROVIDER_SA }}
service_account: ${{ secrets.GCP_WI_SA }}
token_format: access_token

- name: Configure gcloud
uses: google-github-actions/setup-gcloud@v2
Expand Down

0 comments on commit dfcb513

Please sign in to comment.