Documentation / Guides / PR Labeling
Automatic PR Labeling
Automatically label pull requests based on their title prefix.
Keep your pull requests organized by automatically applying labels based on conventional commit prefixes in the PR title. This workflow runs entirely on WorkerRun — it only needs a single GitHub API call, making it a perfect fit for V8 isolates.
Note: This example uses actions/github-script@v8 for inline JavaScript. WorkerRun also supports run: steps with 80+ built-in shell commands (echo, curl, jq, grep, sed, etc.) in V8 mode, and full bash in container mode. See Supported Actions for details.
Workflow
name: PR Labeling
on:
pull_request:
types: [opened, edited]
jobs:
label:
runs-on: worker-run
steps:
- name: Auto-label by title
uses: actions/github-script@v8
with:
script: |
const { data: pr } = await github.rest.pulls.get({
...context.repo,
pull_number: context.issue.number,
});
const title = pr.title;
const labels = [];
if (title.startsWith("feat:")) labels.push("feature");
if (title.startsWith("fix:")) labels.push("bug");
if (title.startsWith("docs:")) labels.push("documentation");
if (title.startsWith("chore:")) labels.push("chore");
if (labels.length > 0) {
await github.rest.issues.addLabels({
...context.repo,
issue_number: context.issue.number,
labels,
});
}Note
Labels must already exist in your repository before they can be added by the workflow. Create them manually in your repo settings under Issues → Labels, or use the GitHub API to create them programmatically.