Repository navigation
Add a script that sets up an organisation for the review workflow - #42
Open
cipherstash-agent wants to merge 4 commits into
Open
cipherstash-agent wants to merge 4 commits into
cipherstash-agent wants to merge 4 commits into
Conversation
… workflow scripts/setup-organisation.sh creates or reuses the membership GitHub App (with the manifest flow and a local listener, or a pasted address without python3), installs it, and stores CLAUDE_REVIEW_APP_CLIENT_ID, CLAUDE_REVIEW_APP_PRIVATE_KEY, CLAUDE_ROUTINE_TOKEN and CLAUDE_ROUTINE_TRIGGER_ID as organisation settings. --check reports the settings and whether the app is installed; --rotate-key replaces the app's private key. Keys and tokens only travel on stdin to gh. Tested against a stand-in gh and browser; shellcheck added to the checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Jmn7rUm51nEBboQCAYhQ3
- The listener runs on macOS's python3 (3.9): postponed annotations. It threads requests with a timeout, so an idle browser connection cannot hold it up, and compares the state as bytes, so a non-ASCII one is refused rather than crashing it. - Without a usable python3 (3.7 or later), or if the listener does not start, the script falls back to the pasted address, and checks that address carries this run's state. - The script stops if GitHub's answer has no private key, and says what to do if storing it fails. - Only a key file GitHub downloaded to ~/Downloads is deleted by default. - If the installed apps cannot be listed, setup offers to keep the app. Reusing the app already stored offers to keep its key. - --check reports settings not visible to all repositories. - The manifest's url is the organisation's; no unquoted glob or tilde in quotes for shellcheck. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Jmn7rUm51nEBboQCAYhQ3
Author
|
integration-test: received ready request from https://github.com/cipherstash/workflows/actions/runs/44668562986/attempts/1 Generated by Claude Code |
SC1007: write empty assignments as ''. SC2016 in check-lock: the backticks are Markdown for the job summary, so the finding is disabled on that line with the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Jmn7rUm51nEBboQCAYhQ3
The listener now takes the code only after it has answered the callback, so the threaded server cannot exit while the browser's "Done" page is still being sent. The listener tests drop the closed stdin, which communicate() rejects before Python 3.13. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Jmn7rUm51nEBboQCAYhQ3
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.
Requested by User · project thread
What this does
Adds
scripts/setup-organisation.sh. An organisation owner runs it on their own computer to set up everything the review workflow needs:The membership GitHub App. The script either creates a new app with GitHub's app manifest flow, or reuses an existing one, then has you install it on the organisation. A new app is private, has only "Members: read", and has no webhook.
Four organisation settings, each visible to all repositories:
CLAUDE_REVIEW_APP_CLIENT_IDCLAUDE_REVIEW_APP_PRIVATE_KEYCLAUDE_ROUTINE_TOKENCLAUDE_ROUTINE_TRIGGER_IDRe-running is safe: a setting that is already there is kept unless you say to replace it. There are two other modes:
--checkchanges nothing. It reports what is missing and whether an app with the stored client id is installed, has "Members: read", is not suspended, and is visible to all repositories. A missing installation is the failure seen on fix!: let the 👀 reaction through, and name the membership App by its client ID #41's first live comment command.--rotate-keyreplaces the app's private key.Private keys and tokens only reach
gh secret setthrough stdin. They are never printed, never passed as a command argument, and never written to disk by the script. The one exception is the.pemfile GitHub downloads for--rotate-key, which the script offers to delete.The script needs only
gh(with theadmin:orgscope) andjq, and runs on macOS's bash 3.2. It usespython33.7 or later, if present, for a small listener on 127.0.0.1 that catches GitHub's answer after the app is created. Without it, you paste the address the browser lands on instead, and the script checks that it came from this run.The workflow side, which reads
CLAUDE_REVIEW_APP_CLIENT_IDthrough the newapp-client-idinput, is on #41. This PR only stores the settings under those names.Tests
tests/test_setup_organisation.pyhas 43 tests. They run the script against a stand-inghand a stand-in browser. They cover:--check, a fresh organisation, re-runs, existing apps, the paste fallback, and--rotate-key;shellcheckjob lintsscripts/setup-organisation.shand.github/scripts/check-lock. shellcheck was not available locally, so this job's first run is on this PR.Generated by Claude Code