fix: authenticate the module fetch for the private commitlint repo - #3
Merged
Conversation
The action installs the linter with `go install`, which fetches over HTTPS with no credentials. While DivergentCodes/commitlint is private that fails with "terminal prompts disabled", so the action could not run at all — the self-test was gated off for exactly this reason. Rewrite only `github.com/DivergentCodes/` URLs to carry a token, so it is never offered to another host or org, and set GOPRIVATE so the public proxy and checksum database are bypassed rather than consulted and failed. The token is passed via the environment, not argv, and a trap removes the global git config afterwards so it does not leak into later steps. All of this becomes a no-op once commitlint is public. The approach is taken from agent/fix-action-yaml, which solved this problem before this repo's rewrite did. Re-enable the self-test. It now probes whether the module is reachable and runs whenever it is, either because commitlint is public or because a cross-repo COMMITLINT_READ_TOKEN is available; the default github.token is scoped to this repository and cannot read a different private one. Verified the probe returns false for commitlint today and true for a public module. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSrrciEDBTuFNMtKocScML
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.
Removes the blocker I flagged in #2: the action installs the linter with
go install, which fetches over HTTPS with no credentials, so whileDivergentCodes/commitlintis private it dies withterminal prompts disabled. The action couldn't run at all, and the self-test was gated off for exactly that reason.Credit where it's due
This approach comes from
agent/fix-action-yaml, a branch already on this repo (authored Jul 27, predating my work). I found it while cleaning up and it had solved this problem before I did. I've ported itsinsteadOfidea here.I did not merge that branch wholesale: it fixes the YAML by collapsing the Python to one line but keeps the API-based commit fetching, so it retains the four defects #2 removed —
per_page=250silently capped at 100, unreachable|| status=1in warn mode, theALLOW_REVERT_PREFIXcomment describing merge commits, and an unpinnedactions/setup-go@v5. This PR takes its good idea onto the cleaned-up base.agent/fix-action-yamlcan be deleted once this merges.What it does
Scoped deliberately:
github.com/DivergentCodes/URLs are rewritten, so the token is never offered to another host or org.GOPRIVATEbypasses the public proxy and checksum database, which cannot see a private module and would fail the fetch rather than fall through.trapunsets the global git config on exit, so the credential doesn't linger for later steps in the job.All of it becomes a no-op once
commitlintis public — the rewrite still matches, but the fetch would have succeeded anyway.Self-test re-enabled
#2 gated it on a
COMMITLINT_PUBLICvariable. That's no longer the right condition, since auth now works regardless. The remaining constraint is subtler: the defaultgithub.tokenis scoped to this repository and cannot read a different private one, so a cross-repo token is needed whilecommitlintstays private.The job now probes reachability and runs when either condition holds — module is public, or
COMMITLINT_READ_TOKENis present — and skips with a::notice::otherwise. Verified the probe returns false forcommitlinttoday and true for a known-public module, so it isn't vacuously passing.To see the self-test actually run
Set a
COMMITLINT_READ_TOKENsecret with read access toDivergentCodes/commitlint. Otherwise it skips until that repo is public — which is fine, and no longer blocks the action itself from working.Verification
action.ymland the workflow parse;actionlintcleanaction.ymlexactly (no undocumented or phantom inputs)🤖 Generated with Claude Code
https://claude.ai/code/session_01VSrrciEDBTuFNMtKocScML