Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github action for auto labeler

I am trying to automate applying label to the GitHub PRs.

I came across this awesome GitHub Action I am not able to understand on where to put labels and any[] or all[]

This is what I have tried so far -

# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration.  For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request]

jobs:
  label:
  
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write

    steps:
    - uses: actions/labeler@v2
      with:
        repo-token: "${{ secrets.GITHUB_TOKEN }}"
        sync-labels: true
        
    - name: Applying labels.
      deployment:
      - any: ['deployment/backend-stack/deployment.yaml']
    
like image 761
Jeet Patel Avatar asked Mar 04 '26 03:03

Jeet Patel


1 Answers

As described in the official documentation you need to have two files in your .github/ folder:

  • actual workflow is defined in .github/workflows/labeler.yml
  • configuration is set in .github/labeler.yml

Difference of the key words any and all:

  • any: match ALL globs against ANY changed path
  • all: match ALL globs against ALL changed paths

Example

.github/workflows/labeler.yml

name: Labeler
on: [pull_request]

jobs:
  label:
  
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write

    steps:
    - uses: actions/labeler@v2
      with:
        repo-token: "${{ secrets.GITHUB_TOKEN }}"
        sync-labels: true

.github/labeler.yml

deployment:
- any: ['deployment/backend-stack/deployment.yaml']
like image 79
Michael Heil Avatar answered Mar 07 '26 05:03

Michael Heil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!