feat: mirror kp-pre-commit-hooks to maritimeais GHES on push to main - #85
Closed
93medmokhtar wants to merge 1 commit into
Closed
feat: mirror kp-pre-commit-hooks to maritimeais GHES on push to main#8593medmokhtar wants to merge 1 commit into
93medmokhtar wants to merge 1 commit into
Conversation
… on push to main Adds .github/workflows/mirror-to-ghes.yml that pushes a full git mirror to maritimeais.ghe.com/mais/kp-pre-commit-hooks on every push to main (and on manual workflow_dispatch). Mirrors the approach used in Kpler/github-actions#587: short-lived GitHub App installation token (no PAT), bare clone + git push --mirror, instance-specific values as env vars, and a concurrency group to serialize runs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Closing: not needed. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds
.github/workflows/mirror-to-ghes.ymlthat pushes a full git mirror of this repo tomaritimeais.ghe.com/mais/kp-pre-commit-hookson every push tomain(plus manualworkflow_dispatch). This makes the pre-commit hooks resolvable from repos on themaisGHES instance (needed by the cookiecutter-pythonmaritimeaistarget, which referenceshttps://maritimeais.ghe.com/mais/kp-pre-commit-hooks).Same approach as Kpler/github-actions#587:
git clone --bare+git push --mirrorso every branch and tag syncs faithfully (tag refs matter here: pre-commit pinsrev:to tags likev0.60.0).envvars at the top.cancel-in-progress: false) serializes runs so no push is dropped.Pre-requisites — one-time manual setup
1. Create the target repo on the GHES⚠️ (does not exist yet)
git push --mirrorrequires the destination to exist. Onhttps://maritimeais.ghe.com, create an empty repomais/kp-pre-commit-hooks(no README/gitignore/license — it must be empty so the mirror push isn't rejected). Match visibility tomais/github-actions(internal).2. GitHub App on the GHES instance
You can reuse the existing App created for
github-actions(e.g.github-actions-mirror) — it only needs Contents: Read & write. Either:maisorg includeskp-pre-commit-hooks(either "All repositories" or add this repo to the selected list). Reuse the same App ID + private key for the secrets below.mais; note App ID; generate a.pem).3. Add secrets to
github.com/Kpler/kp-pre-commit-hooksSettings → Secrets and variables → Actions:
GHES_APP_IDGHES_APP_PRIVATE_KEY.pemprivate key4. Grant enterprise Actions access on the mirror (if hooks are consumed as actions)
Not required for plain pre-commit
repo:clones (runners just read-clone it). Only needed if some repouses:a workflow/action frommais/kp-pre-commit-hooks:GH_HOST=maritimeais.ghe.com gh api --method PUT /repos/mais/kp-pre-commit-hooks/actions/permissions/access -f access_level=enterpriseTest plan
main→mirror-to-ghestriggers automaticallymirror-to-ghesrun is greenhttps://maritimeais.ghe.com/mais/kp-pre-commit-hookshistory matches github.com (same SHAs, all branches and tags present)mainupdates the GHES mirror within seconds🤖 Generated with Claude Code