-
Notifications
You must be signed in to change notification settings - Fork 1
Resolve HB-001: transfer to Lucent-Financial-Group; land GitHub-settings-as-code + drift detector #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Resolve HB-001: transfer to Lucent-Financial-Group; land GitHub-settings-as-code + drift detector #45
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
51ae585
Resolve HB-001: transfer to Lucent-Financial-Group; land GitHub-setti…
AceHack a31ccc6
fix(lints): unblock PR #45 — markdownlint, actionlint, shellcheck
AceHack 9034117
fix: restore administration:read + actionlint -ignore workaround
AceHack 9ea7442
snapshot: expand coverage — repo-level keys + 5 new endpoints
AceHack a2bd943
fix(pr#45): address Copilot actionable findings at source
AceHack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: github-settings-drift | ||
|
|
||
| # Weekly drift detector for GitHub repo settings that live outside the | ||
| # declarative-in-tree surface (rulesets, branch protection, Actions | ||
| # variables, environments, Pages, CodeQL default-setup state, etc.). | ||
| # Compares live `gh api` output against the checked-in expected snapshot | ||
| # at tools/hygiene/github-settings.expected.json. Drift blocks this | ||
| # workflow; resolve by either reverting the setting in GitHub or | ||
| # re-snapshotting and committing the new expected. | ||
| # | ||
| # Security note (safe-pattern compliance): this workflow only consumes | ||
| # first-party trusted context — `secrets.GITHUB_TOKEN` and | ||
| # `github.repository` (the owner/repo string). No user-authored | ||
| # fields (issue title, PR body, commit message, head_ref, etc.) are | ||
| # referenced. Both trusted values are passed via env: into the run | ||
| # block and quoted there, matching the recommended safe pattern from | ||
| # https://github.blog/security/vulnerability-research/how-to-catch-github-actions-workflow-injections-before-attackers-do/ | ||
| # | ||
| # See docs/GITHUB-SETTINGS.md + docs/FACTORY-HYGIENE.md row #40. | ||
|
|
||
| on: | ||
| schedule: | ||
| # Weekly Mondays 14:17 UTC — off the hour to avoid the GHA | ||
| # cron thundering-herd. | ||
| - cron: "17 14 * * 1" | ||
| workflow_dispatch: {} | ||
| # Also run on any change to the expected snapshot or the detector | ||
| # itself, so a PR that updates expected gets an immediate green | ||
| # signal that the snapshot matches reality at merge time. | ||
| pull_request: | ||
| paths: | ||
| - "tools/hygiene/github-settings.expected.json" | ||
| - "tools/hygiene/snapshot-github-settings.sh" | ||
| - "tools/hygiene/check-github-settings-drift.sh" | ||
| - ".github/workflows/github-settings-drift.yml" | ||
|
|
||
| permissions: | ||
| # Rulesets, branch protection, security_and_analysis, | ||
| # secrets counts, deploy keys, webhooks require | ||
| # `administration: read`. `actions: read` covers workflow | ||
| # reads + Actions variables + environments. `contents: read` | ||
| # is the baseline for `actions/checkout`. | ||
| contents: read | ||
| actions: read | ||
| administration: read | ||
|
|
||
| concurrency: | ||
| group: github-settings-drift | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| check: | ||
| name: check drift | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: check drift | ||
| env: | ||
| # Both values below are first-party trusted context. | ||
| # No user-authored input is used anywhere in this workflow. | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GH_REPO: ${{ github.repository }} | ||
| run: | | ||
| set -euo pipefail | ||
| tools/hygiene/check-github-settings-drift.sh --repo "$GH_REPO" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,254 @@ | ||||||
| # GitHub repo settings — declared state | ||||||
|
|
||||||
| This doc is the **declarative source of truth** for every GitHub | ||||||
| repo setting that GitHub does not itself expose as a checked-in | ||||||
| config file. Workflow YAML, CODEOWNERS, Dependabot config, and | ||||||
| pre-commit hooks are already declarative in-tree — not tracked | ||||||
| here. What *is* tracked here: click-ops toggles that live inside | ||||||
| GitHub's UI or require API calls to change. | ||||||
|
|
||||||
| The machine-readable companion is | ||||||
| [`tools/hygiene/github-settings.expected.json`](../tools/hygiene/github-settings.expected.json). | ||||||
| That JSON file is **authoritative** — if this markdown ever | ||||||
| disagrees with it, the JSON wins and this file gets updated. | ||||||
|
|
||||||
| Motivation (human maintainer, 2026-04-21): | ||||||
|
|
||||||
| > "its nice having the expected settings declarative defined" | ||||||
| > | ||||||
| > "i hate things in GitHub where I can't check in the | ||||||
| > declarative settgins so we will save a back[up]" | ||||||
|
|
||||||
| The same day we transferred `AceHack/Zeta` → | ||||||
| `Lucent-Financial-Group/Zeta` and discovered that GitHub's | ||||||
| org-transfer code path silently flipped `secret_scanning` and | ||||||
| `secret_scanning_push_protection` from `enabled` to `disabled`. | ||||||
| That silent drift is exactly what this system detects. | ||||||
|
|
||||||
| ## How this works | ||||||
|
|
||||||
| 1. **Expected state** is recorded in | ||||||
| `tools/hygiene/github-settings.expected.json` — normalized | ||||||
| output of `tools/hygiene/snapshot-github-settings.sh`. | ||||||
| 2. **Drift detector** is `tools/hygiene/check-github-settings-drift.sh`. | ||||||
| It re-runs the snapshot against the live repo and diffs | ||||||
| against the expected JSON. Exit 0 on match, 1 on drift. | ||||||
| 3. **Cadence** is enforced by | ||||||
| `.github/workflows/github-settings-drift.yml` — weekly cron | ||||||
| + `workflow_dispatch` for manual runs. Drift blocks the | ||||||
|
||||||
| + `workflow_dispatch` for manual runs. Drift blocks the | |
| and `workflow_dispatch` for manual runs. Drift blocks the |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: This workflow runs on
pull_request, but the drift check needsadministration: readendpoints (rulesets, branch protection, hooks, deploy keys). On fork-based PRs (which the repo explicitly allows),GITHUB_TOKENwon't have those permissions and the job will fail noisily. Consider skipping the job for fork PRs (e.g.,if: github.event.pull_request.head.repo.full_name == github.repository) and keeping the check for same-repo PRs + scheduled runs.