Skip to content

Commit eeb8655

Browse files
tablackburnclaude
andcommitted
fix: use env-passthrough for graceful-skip gates
The `secrets` context isn't available in `if:` expressions at any level (GitHub Actions context-availability rules), which is why the previous attempt to use `secrets.X != ''` directly in `if:` failed workflow validation. Standard workaround: declare the secret as a job-level (or step-level) `env:` value, then check `env.X != ''` in the `if:`. ggshield.yaml: secret moved to job-level env, gate is now `env.X != ''` on each step. Step-level env on the action invocation is no longer needed (job-level env is inherited). CI.yaml codecov: secret declared as step-level env, gate is appended to the existing condition. token: also reads from env for consistency. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7f078ac commit eeb8655

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

.github/workflows/CI.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,12 @@ jobs:
118118
./build.ps1 -Task Build,Test -Bootstrap
119119
120120
- name: Upload Coverage to Codecov
121-
if: success() && steps.template_guard.outputs.is_template == 'false' && secrets.CODECOV_TOKEN != ''
121+
if: success() && steps.template_guard.outputs.is_template == 'false' && env.CODECOV_TOKEN != ''
122+
env:
123+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
122124
uses: codecov/codecov-action@v6
123125
with:
124-
token: ${{ secrets.CODECOV_TOKEN }}
126+
token: ${{ env.CODECOV_TOKEN }}
125127
files: out/codeCoverage.xml
126128
flags: ${{ matrix.os }}
127129
fail_ci_if_error: false

.github/workflows/ggshield.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ jobs:
88
scanning:
99
name: GitGuardian Scan
1010
runs-on: ubuntu-latest
11-
# Skip when:
12-
# - Dependabot PR (no secret access, only updates dependencies)
13-
# - GITGUARDIAN_API_KEY not configured (graceful skip for newly-init'd repos
14-
# before the secret is set; Dependabot also lands here because it has no
15-
# secret access, but the explicit actor check above is kept for clarity)
16-
if: github.actor != 'dependabot[bot]' && secrets.GITGUARDIAN_API_KEY != ''
11+
# Skip Dependabot PRs (no secret access, only updates dependencies). The
12+
# secret-presence check is enforced per-step via `env.GITGUARDIAN_API_KEY`
13+
# below, because the `secrets` context isn't available in `if:` expressions.
14+
if: github.actor != 'dependabot[bot]'
15+
env:
16+
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
1717
steps:
1818
- uses: actions/checkout@v6
19+
if: env.GITGUARDIAN_API_KEY != ''
1920
with:
2021
fetch-depth: 0
2122
- uses: GitGuardian/ggshield-action@v1
22-
env:
23-
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
23+
if: env.GITGUARDIAN_API_KEY != ''

0 commit comments

Comments
 (0)