Skip to content

ci: harden dependabot-tidy workflow to allow auto-triggering CI - #602

Open
BjoernKarma wants to merge 1 commit into
mainfrom
ci/tidy
Open

ci: harden dependabot-tidy workflow to allow auto-triggering CI#602
BjoernKarma wants to merge 1 commit into
mainfrom
ci/tidy

Conversation

@BjoernKarma

Copy link
Copy Markdown
Contributor

What changed and why

pull_requestpull_request_target

The old event fired in the PR's fork/bot context with a read-only token, requiring maintainer approval. pull_request_target always runs in the base branch context with a write-capable GITHUB_TOKEN no maintainer authorization needed.

Security safeguard added: we check out the PR by its immutable SHA (pr.head.sha), not the branch name. This prevents a malicious PR from being substituted mid-run. The job is also guarded by github.actor == 'dependabot[bot]'.

GitHub App token for re-triggering CI

A commit pushed with GITHUB_TOKEN is explicitly blocked from re-triggering workflows by GitHub (anti-recursion). A GitHub App token bypasses this restriction. The new step conditionally generates one using actions/create-github-app-token when APP_ID and APP_PRIVATE_KEY secrets exist. Falls back gracefully to GITHUB_TOKEN (push works, but CI won't auto-rerun).

Explicit push target

Checking out by SHA puts git in detached HEAD state. The old git push would fail. Now it uses git push origin HEAD:"$HEAD_REF" with the branch name surfaced from the PR metadata.

workflow_dispatch now accepts pr_number So a maintainer can manually run tidy on any PR without needing to edit the workflow

Copilot AI lite review requested due to automatic review settings August 18, 2026 11:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@BjoernKarma BjoernKarma self-assigned this Aug 18, 2026
@BjoernKarma BjoernKarma added dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code labels Aug 18, 2026

@stefan-ctrl stefan-ctrl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Has harding to prevent go mod tidy jobs overwrite other stuff and generally prevent escalation.

Should try it out, if this solves some issues. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants