Skip to content

Commit 9df51db

Browse files
chore: Skip Vault secret steps on fork PRs (#2759)
1 parent 4c005d8 commit 9df51db

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ jobs:
171171
- name: '@grafana/sign-plugin - use GRAFANA_ACCESS_POLICY_TOKEN to sign generate-panel plugin'
172172
if: ${{ github.event.pull_request.head.repo.fork != true }}
173173
env:
174-
GRAFANA_ACCESS_POLICY_TOKEN: ${{ fromJSON(steps.get-secrets.outputs.secrets).GRAFANA_ACCESS_POLICY_TOKEN }}
174+
# Step env is evaluated even when the step is skipped, so fall back to '{}'
175+
# to keep fromJSON from failing the job on fork PRs where get-secrets is skipped.
176+
GRAFANA_ACCESS_POLICY_TOKEN: ${{ fromJSON(steps.get-secrets.outputs.secrets || '{}').GRAFANA_ACCESS_POLICY_TOKEN }}
175177
run: sign-plugin --rootUrls http://www.example.com --signatureType private
176178
working-directory: ./${{ env.WORKING_DIR }}
177179
test-updates:
@@ -477,7 +479,9 @@ jobs:
477479
- name: '@grafana/sign-plugin - use GRAFANA_ACCESS_POLICY_TOKEN to sign generate-panel plugin'
478480
if: ${{ matrix.workingDir == 'myorg-nobackend-panel' && github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.fork != true }}
479481
env:
480-
GRAFANA_ACCESS_POLICY_TOKEN: ${{ fromJSON(steps.get-secrets.outputs.secrets).GRAFANA_ACCESS_POLICY_TOKEN }}
482+
# Step env is evaluated even when the step is skipped, so fall back to '{}'
483+
# to keep fromJSON from failing the job on fork PRs where get-secrets is skipped.
484+
GRAFANA_ACCESS_POLICY_TOKEN: ${{ fromJSON(steps.get-secrets.outputs.secrets || '{}').GRAFANA_ACCESS_POLICY_TOKEN }}
481485
run: sign-plugin --rootUrls http://www.example.com --signatureType private
482486
working-directory: ./${{ matrix.workingDir }}
483487

.github/workflows/playwright.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ jobs:
6262
- name: Install Playwright Browsers
6363
run: npx playwright install --with-deps chromium
6464

65+
# Fork PRs never get an OIDC id-token, so Vault secrets are unavailable there.
66+
# Skipping the Docker Hub login falls back to anonymous image pulls (rate-limit risk only).
6567
- name: Get secrets for DockerHub login
6668
id: get-secrets
69+
if: ${{ github.event.pull_request.head.repo.fork != true }}
6770
uses: grafana/shared-workflows/actions/get-vault-secrets@9f37f656e063f0ad0b0bfc38d49894b57d363936 # v1.2.1
6871
with:
6972
common_secrets: |
@@ -72,10 +75,11 @@ jobs:
7275
export_env: false
7376

7477
- name: Log in to Docker Hub
78+
if: ${{ github.event.pull_request.head.repo.fork != true }}
7579
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
7680
with:
77-
username: ${{ fromJSON(steps.get-secrets.outputs.secrets).DOCKERHUB_USERNAME }}
78-
password: ${{ fromJSON(steps.get-secrets.outputs.secrets).DOCKERHUB_PASSWORD }}
81+
username: ${{ fromJSON(steps.get-secrets.outputs.secrets || '{}').DOCKERHUB_USERNAME }}
82+
password: ${{ fromJSON(steps.get-secrets.outputs.secrets || '{}').DOCKERHUB_PASSWORD }}
7983

8084
- name: Start Grafana
8185
working-directory: ./packages/plugin-e2e

0 commit comments

Comments
 (0)