Skip to content

chore: validate fork PRs without pull_request_target checkout - #170

Merged
badja-dev merged 3 commits into
Kometa-Team:developfrom
badja-dev:chore/safe-fork-pr-ci
Nov 12, 2026
Merged

badja-dev merged 3 commits into
Kometa-Team:developfrom
badja-dev:chore/safe-fork-pr-ci

Conversation

@badja-dev

@badja-dev badja-dev commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Description

validate-pull.yml runs on pull_request_target and checks out the fork PR's code, so actions/checkout v7 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 with secrets.PAT, commits PART back 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 on pull_request (read-only token, no secrets), and fork PRs are promoted to an internal branch by a maintainer before anything with secrets runs.

  • New ci.yml on pull_request with guard, validate (change detection and spellcheck), tests, docker-build and a single ci-status gate. The docker build only runs for same-repo PRs with the docker label, uses docker buildx build with no layer cache, and no longer commits PART. The existing tests/ unittest suite now runs in CI, which it never did before.
  • New .github/scripts/classify-changes.sh holds the "does this change trigger a docker build" rules (unchanged), shared by ci.yml and increment-build.yml.
  • New promote-fork-pr.yml, ported from Kometa with base develop. A maintainer applies internal-test to a fork PR and the commit is copied to automation/fork-pr-N as a draft internal PR. Fork code is never checked out or run in the pull_request_target context, and the docker label must be re-applied on the internal PR after review.
  • tag-cleanup.yml set tag-name but read tag_name, so it always requested tags//. 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 deletes latest, develop, master or version tags.
  • increment-build.yml passes head.ref and head.repo.full_name through 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.yml is removed. New workflows pin actions to commit SHAs (the same SHAs Kometa uses).

Rollout: ci.yml runs from the PR's own merge commit, so it applies as soon as this is on develop (and it runs on this PR). The pull_request_target workflows (promote-fork-pr.yml, tag-cleanup.yml, increment-build.yml, and the removal of validate-pull.yml) are read from the default branch, so they only take effect when a release reaches master. Until then a same-repo PR labelled docker builds twice (old job and new) and the old job still commits PART, so please avoid the docker label until then. The PART file is left in place because master's increment-build.yml still reads and stages it.

Before the release: create the docker and internal-test labels (neither exists today), and confirm the GitHub App behind APP_ID/APP_TOKEN has contents, pull requests and workflows write access. Promoting a PR that edits workflow files needs workflows.

Testing: python -m unittest discover -s tests -v passes locally (19 tests), and the validate and tests jobs run on this PR. The docker-build and promotion paths cannot run before a release, so promote-fork-pr.yml is kept identical to Kometa's copy apart from the base branch, the docker label wording and the comment marker.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change (non-code changes affecting only the wiki)
  • Infrastructure change (changes related to the github repo, build process, or the like)

Checklist

  • My code was submitted to the develop branch of the repository.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@badja-dev
badja-dev merged commit fcd725a into Kometa-Team:develop Nov 12, 2026
6 of 7 checks passed
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.

1 participant