Skip to content

ci: add workflow to auto-label PRs by changed paths#1158

Open
mr-raj12 wants to merge 1 commit intoasyncapi:masterfrom
mr-raj12:ci/pr-labeler-workflow
Open

ci: add workflow to auto-label PRs by changed paths#1158
mr-raj12 wants to merge 1 commit intoasyncapi:masterfrom
mr-raj12:ci/pr-labeler-workflow

Conversation

@mr-raj12
Copy link
Copy Markdown

Description

Adds a new workflow that automatically applies the repo's existing area/* labels to pull requests based on which files changed. Uses actions/labeler@v5 with a path-to-label mapping file.

Closes #1157.

Why

asyncapi/parser-js already has a rich area/* label taxonomy (area/javascript, area/typescript, area/docs, area/ci-cd, area/java, area/go, area/design), but nothing applies these labels to PRs automatically:

  • Dependabot PRs get dependencies + javascript (set by Dependabot itself).
  • Regular PRs — including ci: PRs like ci: update of files from global .github repo #1149 — land with no area/* label.
  • The existing add-good-first-issue-labels.yml workflow is comment-triggered (/gfi <area>) and only targets issues, not PRs.

Result: maintainers either label PRs by hand or skip it, and filtering open PRs by area is unreliable.

Changes

Two new files (both are new, so this does not conflict with workflows centrally managed in asyncapi/.github):

.github/labeler.yml

Path-to-label mapping. Uses only labels that already exist on the repo:

Label Paths
area/ci-cd .github/**, .changeset/**, turbo.json
area/docs **/*.md, assets/**
area/typescript **/*.ts, **/*.tsx
area/javascript **/*.js, **/*.cjs, **/*.mjs
dependencies package.json, package-lock.json, packages/*/package.json

.github/workflows/labeler.yml

Runs on pull_request_target (required by actions/labeler so it has pull-requests: write on PRs from forks) and calls actions/labeler@v5. sync-labels: true removes a label if a later push no longer matches — keeps labels honest as the PR evolves.

Permissions are scoped to only what's needed:

permissions:
  contents: read
  pull-requests: write

Notes for reviewers

  • No label taxonomy change — every label in labeler.yml is one the repo already uses.
  • pull_request_target is used (not pull_request) per the actions/labeler docs, so PRs from forks can be labeled. The action only reads the PR diff; it does not check out or execute PR code.
  • The mapping can be trivially tuned — happy to adjust the globs based on maintainer preference. For example, I considered adding per-package labels (area/parser, area/multi-parser) but stuck to labels that already exist on the repo.
  • First-run behavior: existing open PRs will not be labeled retroactively; labels apply to new PR events after merge.

Adds .github/labeler.yml and .github/workflows/labeler.yml that use
actions/labeler@v5 to apply the repo's existing area/* labels to PRs
based on which files changed.

Mapping uses only labels that already exist on the repo:
- area/ci-cd for .github/**, .changeset/**, turbo.json
- area/docs for **/*.md and assets/**
- area/typescript for **/*.{ts,tsx}
- area/javascript for **/*.{js,cjs,mjs}
- dependencies for package.json and lockfiles

Both files are new, so this does not conflict with workflows that are
centrally managed in asyncapi/.github.

Refs asyncapi#1157
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 22, 2026

⚠️ No Changeset found

Latest commit: f4c9a70

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sonarqubecloud
Copy link
Copy Markdown

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.

[FEATURE] Automatically label pull requests based on changed file paths

1 participant