Skip to content

Commit 0789629

Browse files
authored
feat!: only allow direct workload identity federation in login-to-gar (#1009)
* Remove service account auth and deprecation message Removes old deprecated authentication after all GAR ops have moved to Direct WIF. * Remove environment from login-to-gar test
1 parent 2aeb3e6 commit 0789629

File tree

3 files changed

+0
-49
lines changed

3 files changed

+0
-49
lines changed

.github/workflows/test-login-to-gar.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ permissions:
2626

2727
jobs:
2828
test:
29-
strategy:
30-
matrix:
31-
enviromnent:
32-
- dev
33-
- prod
3429
runs-on: ubuntu-latest
3530
# Don't run for forks - they don't have access to secrets
3631
if: github.event.pull_request.head.repo.full_name == github.repository
@@ -49,5 +44,4 @@ jobs:
4944
id: test-login-to-gar
5045
uses: ./actions/login-to-gar
5146
with:
52-
environment: ${{ matrix.enviromnent }}
5347
registry: "us-docker.pkg.dev"

actions/login-to-gar/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
id: login-to-gar
2424
with:
2525
registry: "<YOUR-GAR>" # e.g. us-docker.pkg.dev
26-
environment: "prod" # can be either dev/prod
2726
```
2827
2928
<!-- x-release-please-end-version -->
@@ -33,7 +32,6 @@ jobs:
3332
| Name | Description | Default |
3433
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
3534
| `registry` | Google Artifact Registry to authenticate against. | `us-docker.pkg.dev` |
36-
| `environment` | Environment for pushing artifacts (can be either dev or prod). | `dev` |
3735
| `delete_credentials_file` | Delete the credentials file after the action is finished. If you want to keep the credentials file for a later step, set this to false. | `false` |
3836

3937
> [!WARNING]

actions/login-to-gar/action.yaml

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ inputs:
55
description: |
66
Google Artifact Registry to authenticate against.
77
default: "us-docker.pkg.dev"
8-
environment:
9-
description: |
10-
Environment for pushing artifacts (can be either dev or prod).
11-
default: dev
128
delete_credentials_file:
139
description: |
1410
Delete the credentials file after the action is finished.
@@ -18,42 +14,7 @@ inputs:
1814
runs:
1915
using: composite
2016
steps:
21-
- name: Construct service account
22-
id: construct-service-account
23-
shell: sh
24-
env:
25-
ENVIRONMENT: ${{ inputs.environment }}
26-
run: |
27-
SERVICE_ACCOUNT="github-${{ github.repository_id }}-${ENVIRONMENT}@grafanalabs-workload-identity.iam.gserviceaccount.com"
28-
echo "service_account=${SERVICE_ACCOUNT}" | tee -a "${GITHUB_OUTPUT}"
29-
# if service account exists, then authenticate using the service account
30-
- uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
31-
name: Auth with service account
32-
id: auth_with_service_account
33-
with:
34-
token_format: access_token
35-
workload_identity_provider: "projects/304398677251/locations/global/workloadIdentityPools/github/providers/github-provider"
36-
service_account: ${{ steps.construct-service-account.outputs.service_account }}
37-
continue-on-error: true
38-
- name: Service account deprecation warning
39-
if: ${{ steps.auth_with_service_account.outputs.access_token != '' }}
40-
shell: sh
41-
run: |
42-
echo "::warning::Warning: Authenticating with a Service Account is going to be deprecated on April 30. \
43-
If you don't want to be affected by this change, either pin your action according to \
44-
https://github.com/grafana/shared-workflows/blob/main/actions/login-to-gar/README.md or go to your repository config \
45-
and stop using Service Accounts."
46-
# authenticate using the access_token from the auth_with_service_account step
47-
- name: Login to GAR
48-
if: ${{ steps.auth_with_service_account.outputs.access_token != '' }}
49-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
50-
with:
51-
registry: ${{ inputs.registry }}
52-
username: oauth2accesstoken
53-
password: ${{ steps.auth_with_service_account.outputs.access_token }}
54-
# if service account doesn't exist, then authenticate using direct workload identity federation
5517
- uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
56-
if: ${{ steps.auth_with_service_account.outputs.access_token == '' }}
5718
name: Auth with direct WIF
5819
id: auth_with_direct_wif
5920
with:
@@ -109,14 +70,12 @@ runs:
10970
echo "${RUNNER_TEMP}/docker-credential-gcr" >> $GITHUB_PATH
11071
fi
11172
- name: "Configure GCP Artifact Registry"
112-
if: ${{ steps.auth_with_service_account.outputs.access_token == '' }}
11373
id: configure-docker
11474
shell: sh
11575
env:
11676
REGISTRY: ${{ inputs.registry }}
11777
run: docker-credential-gcr configure-docker --registries="${REGISTRY}"
11878
- name: Delete Google Application Credentials file
119-
if: ${{ inputs.delete_credentials_file == 'true' && env.GOOGLE_APPLICATION_CREDENTIALS != '' }}
12079
shell: sh
12180
run: |
12281
if [ -f "${{ env.GOOGLE_APPLICATION_CREDENTIALS }}" ]; then

0 commit comments

Comments
 (0)