Skip to content

Commit 1cf56e5

Browse files
d-csclaude
andauthored
ci: gate optional publish/notify jobs behind repository variables (#3950)
## Summary Several optional workflow jobs fail on forks and private mirrors that lack org-specific secrets or registry permissions. This adds per-job repository-variable gates so those deployments can switch them off without editing workflows — matching the pattern from #3901 (`ENABLE_CLAUDE_CODE` / `ENABLE_WORKFLOW_SECURITY_SCAN`). Two variables, both **default-enabled** (a job runs unless its variable is explicitly `'false'`), so canonical-repo behaviour is unchanged where the variables are unset: **`ENABLE_HELM_PRERELEASE`** — gates the chart-publish jobs that push to `oci://ghcr.io/<owner>/charts` (needs `write_package` on the owner's charts namespace): - `helm-prerelease.yml` → `prerelease` job - `release-helm.yml` → `release` job Without the permission these fail with `403: denied: permission_denied: write_package` on every PR / `helm-v*` tag. The `lint-and-test` jobs (lint + template + kubeconform, no push) always run, so chart validity is still enforced everywhere. **`ENABLE_DEPENDABOT_ALERTS`** — gates the Dependabot notifier crons that need `DEPENDABOT_ALERTS_TOKEN` / `SLACK_BOT_TOKEN` and post to a specific Slack: - `dependabot-critical-alerts.yml` → `alert` job (daily cron) - `dependabot-weekly-summary.yml` → `summary` job (weekly cron) On a fork/mirror these otherwise fire on schedule and fail (or post nowhere) indefinitely. ## Test plan - Variables unset (default): all jobs run as today. - `ENABLE_HELM_PRERELEASE=false`: helm `lint-and-test` runs, publish jobs skip — no 403 on repos lacking `write_package`. - `ENABLE_DEPENDABOT_ALERTS=false`: the two cron jobs skip cleanly (neutral, not failed). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent af526de commit 1cf56e5

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

.github/workflows/dependabot-critical-alerts.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ permissions:
2525
jobs:
2626
alert:
2727
name: Post critical alerts
28+
# Set the ENABLE_DEPENDABOT_ALERTS repository variable to 'false' to turn off
29+
# the Dependabot alert/summary notifiers — e.g. forks/mirrors that lack the
30+
# DEPENDABOT_ALERTS_TOKEN / SLACK_BOT_TOKEN secrets. Defaults to enabled.
31+
if: ${{ vars.ENABLE_DEPENDABOT_ALERTS != 'false' }}
2832
runs-on: ubuntu-latest
2933
environment: dependabot-summary
3034
env:

.github/workflows/dependabot-weekly-summary.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ permissions:
1919
jobs:
2020
summary:
2121
name: Post weekly Dependabot summary
22+
# Set the ENABLE_DEPENDABOT_ALERTS repository variable to 'false' to turn off
23+
# the Dependabot alert/summary notifiers — e.g. forks/mirrors that lack the
24+
# DEPENDABOT_ALERTS_TOKEN / SLACK_BOT_TOKEN secrets. Defaults to enabled.
25+
if: ${{ vars.ENABLE_DEPENDABOT_ALERTS != 'false' }}
2226
runs-on: ubuntu-latest
2327
environment: dependabot-summary
2428
env:

.github/workflows/helm-prerelease.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,15 @@ jobs:
6868

6969
prerelease:
7070
needs: lint-and-test
71+
# Set the ENABLE_HELM_PRERELEASE repository variable to 'false' to turn off
72+
# publishing the chart to GHCR — e.g. forks/mirrors that lack write_package
73+
# on the owner's charts namespace. Defaults to enabled; the lint-and-test
74+
# job above always runs regardless.
7175
if: |
72-
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
76+
vars.ENABLE_HELM_PRERELEASE != 'false' &&
77+
((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
7378
github.event_name == 'push' ||
74-
github.event_name == 'workflow_dispatch'
79+
github.event_name == 'workflow_dispatch')
7580
runs-on: ubuntu-latest
7681
permissions:
7782
contents: read

.github/workflows/release-helm.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ jobs:
6363

6464
release:
6565
needs: lint-and-test
66+
# Set the ENABLE_HELM_PRERELEASE repository variable to 'false' to turn off
67+
# publishing the chart to GHCR — e.g. forks/mirrors that lack write_package
68+
# on the owner's charts namespace. Defaults to enabled; the lint-and-test
69+
# job above always runs regardless.
70+
if: ${{ vars.ENABLE_HELM_PRERELEASE != 'false' }}
6671
runs-on: ubuntu-latest
6772
permissions:
6873
contents: write # for gh-release

0 commit comments

Comments
 (0)