GitHub action to copy labels from any issues closed by a pull request into the pull request itself.
---
name: Sync Closing Labels
on:
pull_request_target
jobs:
sync:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Sync labels with closing issues
uses: williambdean/closing-labels@v0.0.7The action uses github.token by default — no additional secrets required. The workflow must grant pull-requests: write permission.
| Input | Required | Default | Description |
|---|---|---|---|
gh_token |
No | ${{ github.token }} |
GitHub token with pull-requests: write permission |
exclude |
No | "" |
Comma-separated list of labels to never add |
respect_unlabeled |
No | "true" |
If "true", labels manually removed from the PR will not be re-added |
owner |
No | ${{ github.repository_owner }} |
Repository owner |
repo |
No | ${{ github.event.repository.name }} |
Repository name |
pr_number |
No | ${{ github.event.number }} |
Pull request number |
- uses: williambdean/closing-labels@v0.0.7
with:
exclude: "wontfix,duplicate"- uses: williambdean/closing-labels@v0.0.7
with:
respect_unlabeled: "false"- uses: williambdean/closing-labels@v0.0.7
with:
gh_token: ${{ secrets.MY_GITHUB_TOKEN }}- Queries the GitHub GraphQL API to find all issues referenced as "closing" by the pull request
- Collects all labels from those issues
- Optionally subtracts any labels that were manually removed from the PR (
respect_unlabeled) - Optionally filters out labels in the
excludelist - Applies the remaining labels to the pull request via the GitHub REST API
Please see our Security Policy for information on how to report security vulnerabilities.
Build and enter the Docker container locally:
make build
make interactiveFrom inside the container, run the action with the required environment variables:
GH_TOKEN="$(gh auth token)" \
INPUT_OWNER="williambdean" \
INPUT_REPO="closing-labels" \
INPUT_PR_NUMBER="21" \
INPUT_EXCLUDE="wontfix,duplicate" \
INPUT_RESPECT_UNLABELED="true" \
INPUT_DRY_RUN="true" \
closing-labelsSet INPUT_DRY_RUN="true" to preview what labels would be applied without making any changes.
