GitHub Action: Label Synchronization
This GitHub Action workflow automates the synchronization of GitHub labels based on a YAML configuration file. It runs on changes to the label configuration or its workflow file and ensures consistency in label management across the repository.
Workflow Details
Triggers (on)
push:- Triggered when changes are pushed to the
mainbranch. - Monitored paths:
.github/labels.yml: The YAML file containing label definitions..github/workflows/labels.yml: The workflow configuration for label synchronization.
- Triggered when changes are pushed to the
pull_request:- Triggered when pull requests modify the
.github/labels.ymlor.github/workflows/labels.ymlfiles.
- Triggered when pull requests modify the
Job Details
labeler
runs-on: ubuntu-latest
Steps:
- Checkout repository:
-
Uses
actions/checkout@v4to fetch the repository content. -
Run Labeler:
- Uses
crazy-max/ghaction-github-labeler@v5to synchronize labels based on the.github/labels.ymlfile. - Inputs:
github-token: A personal access token (PAT) stored in the repository's secrets for authentication.yaml-file: Specifies the path to the label configuration file (.github/labels.yml).dry-run: Simulates the label synchronization process when the workflow is triggered by a pull request (truefor pull requests,falseotherwise).exclude: Excludes specific labels from synchronization. Here, labels matchinghelp*or*issueare excluded.
In summary, this workflow ensures that GitHub labels in your repository remain consistent with the definitions in .github/labels.yml. It supports both live updates for pushes and simulation mode for pull requests, providing a robust solution for label management.