Repository navigation
chore: validate fork PRs without pull_request_target checkout - #170
Merged
Merged
Conversation
2 of 6 tasks
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.
Description
validate-pull.ymlruns onpull_request_targetand checks out the fork PR's code, soactions/checkoutv7 now refuses it ("Refusing to check out fork pull request code") and the check fails on every fork PR. Its docker job also checks the fork out withsecrets.PAT, commitsPARTback to the fork branch, then builds and pushes with Docker Hub credentials. This replaces it with the same split Kometa uses: untrusted code only ever runs onpull_request(read-only token, no secrets), and fork PRs are promoted to an internal branch by a maintainer before anything with secrets runs.ci.ymlonpull_requestwith guard, validate (change detection and spellcheck), tests, docker-build and a singleci-statusgate. The docker build only runs for same-repo PRs with thedockerlabel, usesdocker buildx buildwith no layer cache, and no longer commitsPART. The existingtests/unittest suite now runs in CI, which it never did before..github/scripts/classify-changes.shholds the "does this change trigger a docker build" rules (unchanged), shared byci.ymlandincrement-build.yml.promote-fork-pr.yml, ported from Kometa with basedevelop. A maintainer appliesinternal-testto a fork PR and the commit is copied toautomation/fork-pr-Nas a draft internal PR. Fork code is never checked out or run in thepull_request_targetcontext, and thedockerlabel must be re-applied on the internal PR after review.tag-cleanup.ymlsettag-namebut readtag_name, so it always requestedtags//. Fixed that, and moved the fork-controlled values and secrets out of the script text into env. Because the fix makes deletion actually work, it now only runs for same-repo PRs and never deleteslatest,develop,masteror version tags.increment-build.ymlpasseshead.refandhead.repo.full_namethrough env instead of interpolating them into the script, and uses the shared classifier script instead of its inline loop. No other behavior change.validate-pull.ymlis removed. New workflows pin actions to commit SHAs (the same SHAs Kometa uses).Rollout:
ci.ymlruns from the PR's own merge commit, so it applies as soon as this is ondevelop(and it runs on this PR). Thepull_request_targetworkflows (promote-fork-pr.yml,tag-cleanup.yml,increment-build.yml, and the removal ofvalidate-pull.yml) are read from the default branch, so they only take effect when a release reachesmaster. Until then a same-repo PR labelleddockerbuilds twice (old job and new) and the old job still commitsPART, so please avoid thedockerlabel until then. ThePARTfile is left in place becausemaster'sincrement-build.ymlstill reads and stages it.Before the release: create the
dockerandinternal-testlabels (neither exists today), and confirm the GitHub App behindAPP_ID/APP_TOKENhas contents, pull requests and workflows write access. Promoting a PR that edits workflow files needsworkflows.Testing:
python -m unittest discover -s tests -vpasses locally (19 tests), and the validate and tests jobs run on this PR. The docker-build and promotion paths cannot run before a release, sopromote-fork-pr.ymlis kept identical to Kometa's copy apart from the base branch, the docker label wording and the comment marker.Type of Change
Checklist
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.