How actions/labeler works
Project type and purpose
• This is an open-source GitHub Action, written in TypeScript/JavaScript, called “Pull Request Labeler.”
• Its purpose is to automatically apply and synchronize labels on pull requests based on changed-file globs or branch‐name regexps.
File structure
• Top-level configuration and CI/CD
• action.yml – GitHub Action metadata (inputs, outputs, runs).
• .github/workflows – CI pipelines: build, lint, test, security scans, publish.
• .github/labeler.yml (userland) – runtime configuration of which labels map to which globs/regexps.
• Source code
• src/main.ts – entry point invoked by action.yml.
• src/get-inputs/ – modules to read inputs (repo token, config path, pr-number).
• src/api/ – wrappers around GitHub API calls (get-changed-files, get-pull-requests, get-content, set-labels).
• src/branch.ts – logic to match branch names against regexps.
• src/changedFiles.ts – logic to match changed-file paths against glob patterns.
• src/labeler.ts – core orchestration: for each label, evaluate match objects, call set-labels as needed.
• src/utils.ts – shared helpers.
• dist/ – transpiled JavaScript distribution (index.js) that is shipped.
• Testing
• __tests__ – Jest tests for each module.
• __mocks__ – custom mocks for @actions/github.
• Build and config
• tsconfig.json, package.json, .eslintrc.js, jest.config.js, .prettierrc.js
• LICENSE, CONTRIBUTING.md, CODE_OF_CONDUCT.md, etc.
README for additional insights
• Describes v5 breaking changes and the high-level matching logic (any/all AND/OR).
• Shows the required .github/workflows/labeler.yml and key inputs/outputs.
• Explains recommended permissions and event triggers (pull_request_target vs pull_request).