Label linked issues when a PR is submitted or approved - #528
Merged
Merged
Conversation
Ports bb-plugin's pr-submitted-add-label and pr-approved-add-label workflows into a single file, since the issue-parsing and labeling body is identical between them and only the applied label differs. Runs on ubuntu-latest rather than bb-plugin's self-hosted runner: this repo is public with no self-hosted runners registered, and the job is a single API call with nothing to build. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
Ports bb-plugin's issue-labeling automation into this repo. This is the assistant repo's first GitHub Actions workflow — there was no
.github/directory before.What it does
On a non-draft PR, it parses the PR body for
fixes/closes/resolves #Nand labels each linked open issue:pull_request(opened, synchronize, reopened, edited)status: has pull requestpull_request_reviewsubmitted and approvedstatus: approvedBoth labels were created in this repo to match bb-plugin's colors and descriptions.
Combined rather than two files
bb-plugin keeps these as separate workflows (
pr-submitted-add-label.ymlandpr-approved-add-label.yml), but their issue-parsing and labeling bodies are identical — the only real difference is which label gets applied. So this is one job with both triggers, picking the label fromcontext.eventName.Two incidental improvements fall out of the merge:
$GITHUB_ENVfor a laterif:to read. That collapses into the job-levelif:, dropping a step and the env round-trip.Deliberate differences from bb-plugin
runs-on: ubuntu-latestinstead of[self-hosted, general]. This repo is public and has no self-hosted runners registered to it. Pointing a public repo'spull_requestworkflow at a self-hosted runner would let any fork PR execute on our hardware, and this job is a single GitHub API call with no build step — there's nothing to gain from the self-hosted lane.status: ready for human reviewremoval step is omitted. bb-plugin's approval workflow drops that label after a human approves, but it's set by bb-plugin's AI-review workflow, which this repo doesn't have. The step would be permanently dead here. Worth adding if that workflow ever comes over.actions/github-script@v6is kept as-is to match bb-plugin, though it runs on the deprecated Node 16 and will need a v7 bump at some point.Testing
A workflow can't be exercised before it's on GitHub, so this PR is its own test: it's a same-repo PR, so the
pull_requesthalf runs against this branch on open. It has nofixes #Nin the body, so the expected result is a clean run loggingNo linked issues found in PR body.Approving it should then fire thepull_request_reviewhalf to the same no-op.One thing I couldn't determine ahead of time: fork PRs get a read-only
GITHUB_TOKENon thepull_requestevent, so labeling silently no-ops for them (the script catches and logs it). Whether the same restriction applies topull_request_reviewis unclear to me — the triggering actor there is a reviewer on the base repo, not the fork author. Observable on the first fork PR approval. Org-member branch PRs are unaffected either way.🤖 Generated with Claude Code