Skip to content

chore: validate fork PRs without pull_request_target checkout - #110

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 and ImageMaid use (Kometa-Team/ImageMaid#170): 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), 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. There is no test suite in this repo, so there is no tests job.
  • 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 instead of its inline loop. It also drops cache-to and actions: write from the develop build, because pull_request_target gets a read-only cache token so the cache write fails (the same fix as ImageMaid#160); the job now declares contents: read and packages: write.
  • 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, and confirm the GitHub App behind APP_ID/APP_TOKEN is installed on this repo with contents, pull requests and workflows write access. Promoting a PR that edits workflow files needs workflows.

Testing: the validate job runs on this PR. The docker-build and promotion paths cannot run before a release, so promote-fork-pr.yml, tag-cleanup.yml and increment-build.yml are identical to the copies now on ImageMaid's master (where a throwaway fork PR was promoted, built for amd64 and arm64, and cleaned up end to end), and ci.yml and the classifier differ only by the removed tests job and the overlay_reset.py file name.

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 mentioned this pull request Nov 12, 2026
3 of 6 tasks
@badja-dev
badja-dev merged commit 9e42023 into Kometa-Team:develop Nov 12, 2026
5 of 6 checks passed
@badja-dev
badja-dev deleted the chore/safe-fork-pr-ci branch November 13, 2026 09:20
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