Skip to content

Commit 4940ba0

Browse files
authored
fix: auth on forked repos (#4087)
* fix: support tests on forked repos * checkout and auth as separate steps * remove changes to packages to trigger tests
1 parent 8894707 commit 4940ba0

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

.github/workflows/custard-run-dev.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,25 @@ jobs:
8080
name: (experimental / dev) Custard CI / ${{ github.job }} (${{ matrix.path }})
8181
job-name: ${{ github.job }} (${{ matrix.path }})
8282
if: ${{ !!github.event.workflow_run }}
83+
- name: Checkout
84+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
85+
- name: Authenticate
86+
uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
87+
id: auth
88+
with:
89+
project_id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
90+
workload_identity_provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
91+
service_account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
92+
access_token_lifetime: 600s # 10 minutes
93+
token_format: id_token
94+
id_token_audience: https://action.test/ # service must have this custom audience
95+
id_token_include_email: true
8396
- name: Setup Custard
8497
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/setup-custard@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
8598
with:
8699
path: ${{ matrix.path }}
87100
ci-setup: ${{ toJson(fromJson(needs.affected.outputs.ci-setups)[matrix.path]) }}
88-
project-id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
89-
workload-identity-provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
90-
service-account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
101+
id-token: ${{ steps.auth.outputs.id_token }}
91102
- name: Check in_progress
92103
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
93104
id: in_progress

.github/workflows/custard-run.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,25 @@ jobs:
124124
name: (experimental) Custard CI / ${{ github.job }} (${{ matrix.path }})
125125
job-name: ${{ github.job }} (${{ matrix.path }})
126126
if: ${{ !!github.event.workflow_run }}
127+
- name: Checkout
128+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
129+
- name: Authenticate
130+
uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
131+
id: auth
132+
with:
133+
project_id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
134+
workload_identity_provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
135+
service_account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
136+
access_token_lifetime: 600s # 10 minutes
137+
token_format: id_token
138+
id_token_audience: https://action.test/ # service must have this custom audience
139+
id_token_include_email: true
127140
- name: Setup Custard
128141
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/setup-custard@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
129142
with:
130143
path: ${{ matrix.path }}
131144
ci-setup: ${{ toJson(fromJson(needs.affected.outputs.ci-setups)[matrix.path]) }}
132-
project-id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
133-
workload-identity-provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
134-
service-account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
145+
id-token: ${{ steps.auth.outputs.id_token }}
135146
- name: Check in_progress
136147
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
137148
id: in_progress

0 commit comments

Comments
 (0)