File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 - cron : ' 0 * * * *'
99
1010jobs :
11- labeler :
11+ # this job runs when the workflow was triggered by the 'pull_request' event
12+ pr-labeler :
1213 permissions :
1314 contents : read
1415 pull-requests : write
1516 issues : write
1617 # don't run on PRs from forks (token has no write permissions)
17- if : ${{ github.event.pull_request.head.repo.full_name == github.repository }}
18+ if : ${{ github.event_name == 'pull_request' && github. event.pull_request.head.repo.full_name == github.repository }}
1819 name : " Labeler"
1920 runs-on : ubuntu-latest
2021 steps :
2122 - name : Labeler action
2223 uses : actions/labeler@v7
2324 with :
2425 sync-labels : false
26+
27+ # This job runs when the workflow was triggered by the 'workflow_dispatch' or the 'schedule' event.
28+ # This is neccessary because for PRs from forks the default short-lived GitHub token has no write permissions
29+ # and can not add labels to the PR therefore. This means we have to label all PRs from forks using the 'schedule' event.
30+ scheduled-labeler :
31+ permissions :
32+ contents : read
33+ pull-requests : write
34+ issues : write
35+ # don't run on PRs from forks (token has no write permissions)
36+ if : ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
37+ name : " Label all open PRs"
38+ runs-on : ubuntu-latest
39+ steps :
40+ - name : Fetch open PR numbers
41+ id : fetch-prs
42+ run : |
43+ numbers=$(gh pr list --repo ${{ github.repository }} --state open --limit 500 --json number --jq 'map(.number)')
44+ echo numbers=$numbers >> $GITHUB_OUTPUT
45+ env :
46+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
47+
48+ - name : Labeler action
49+ if : ${{ steps.fetch-prs.outputs.numbers != '' }}
50+ uses : actions/labeler@v7
51+ with :
52+ sync-labels : false
53+ pr-number : ${{ steps.fetch-prs.outputs.numbers }}
You can’t perform that action at this time.
0 commit comments