Skip to content

Add CI to validate key PRs, auto-merge safe ones, and regenerate @all - #643

Merged
djgalloway merged 2 commits into
mainfrom
github-workflow-pr-validation-52ddd5
Aug 14, 2026
Merged

Add CI to validate key PRs, auto-merge safe ones, and regenerate @all#643
djgalloway merged 2 commits into
mainfrom
github-workflow-pr-validation-52ddd5

Conversation

@djgalloway

Copy link
Copy Markdown
Contributor

What changed

  • .github/scripts/validate-keys.sh — validates every ssh/*.pub file a PR adds or modifies (diffed against the merge base). Each non-blank line must parse with ssh-keygen -lf; the check fails on private key material, DSA keys, RSA keys under 2048 bits, empty key files, bad filename characters, and reserved @-prefixed names. It also reports whether the PR touches only ssh/*.pub files.
  • .github/workflows/pr-validate.yml — runs on PRs to main: validate → auto-merge → run ./update. Auto-merge only happens when validation passes and the PR branch lives in this repo (not a fork), the author is an org member/owner/collaborator, the PR isn't a draft, and it changes nothing but ssh/*.pub files. Everything else still gets validated but waits for a human merge. After merging, CI checks out main and runs the existing ./update script (setting branch.main.remote and a git identity first, which the script needs and Actions checkouts don't provide).
  • .github/workflows/regenerate.yml — regenerates the autogenerated branch on any push to main touching ssh/** (manual merges, direct pushes). Needed because pushes made with GITHUB_TOKEN don't trigger other workflows, so the PR workflow runs ./update itself; a shared concurrency group prevents the two from racing.
  • README.rst — documents the new flow.

Why

Merging into this repo grants SSH access to the Sepia lab, so a green key check alone is deliberately not sufficient to auto-merge — the author-association and same-repo gates are the actual access control; validation just catches broken keys before they land.

Notes for reviewers

  • The validation script was tested locally against: valid ed25519/RSA keys, multi-key files with blank lines, unparseable keys, committed private keys, empty files, DSA keys, @-prefixed filenames, mixed key+non-key PRs, and deletion-only PRs.
  • Existing legacy ssh-dss keys are untouched; the policy only applies to files a PR adds or modifies.
  • Repo settings: workflow permissions must allow write. If main gains branch protection requiring reviews, the GITHUB_TOKEN merge will be rejected and would need a bypass or an admin PAT.

Validate every ssh/*.pub file a PR adds or modifies: each line must be a
parseable public key (no private key material, no DSA, RSA >= 2048 bits,
sane filenames, no reserved @-prefixed names).

PRs from repo/org members that only touch ssh/*.pub files are merged
automatically once validation passes, and ./update is then run in CI to
regenerate the autogenerated branch. A push-triggered workflow covers
manually merged PRs, since GITHUB_TOKEN merges don't trigger it from the
auto-merge path.

Signed-off-by: David Galloway <david.galloway@ibm.com>
Tags are mutable; pin to the v7.0.1 commit instead.

Signed-off-by: David Galloway <david.galloway@ibm.com>
@djgalloway
djgalloway merged commit 8c79f26 into main Aug 14, 2026
3 checks passed
@djgalloway
djgalloway deleted the github-workflow-pr-validation-52ddd5 branch August 14, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants