Skip to content

Commit 5ef2b66

Browse files
authored
Merge pull request #89 from PHPCSStandards/feature/ghactions-safeguard-labeler-more
GH Actions: safeguard the PR label workflow some more
2 parents 70ab081 + c7f23e2 commit 5ef2b66

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

.github/workflows/label-new-prs.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,48 @@ name: Label new PRs
22

33
on:
44
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
5+
# The `pull_request_target` event is used for "normal" PRs to label them when they are opened.
6+
# This will use the `labeler.yml` file in the default (master) branch of the repo.
57
pull_request_target:
68
types:
79
- opened
810
- ready_for_review
911

12+
# The `pull_request` event is used for PRs which change the files which handle the labeling to prevent a silently failing action.
13+
# This will use the `labeler.yml` file in the PR branch.
14+
pull_request:
15+
paths:
16+
- '.github/workflows/label-new-prs.yml'
17+
- '.github/labeler.yml'
18+
1019
jobs:
1120
label-new-prs:
1221
runs-on: ubuntu-latest
22+
if: github.repository_owner == 'PHPCSStandards' && github.event_name == 'pull_request_target'
23+
24+
name: Add labels to new PRs
25+
26+
steps:
27+
- name: Label new PRs
28+
uses: srvaroa/labeler@master
29+
env:
30+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
31+
32+
validate-labeler-worflow:
33+
runs-on: ubuntu-latest
34+
if: github.repository_owner == 'PHPCSStandards' && github.event_name == 'pull_request' && github.event.pull_request.merged == false
35+
36+
name: Validate changes to Labeler logic
1337

1438
steps:
15-
- uses: srvaroa/labeler@master
39+
# Checkout is needed to use the `use_local_config` option.
40+
- name: Checkout code
41+
uses: actions/checkout@v3
42+
43+
- name: Verify changes to the labeling logic
44+
uses: srvaroa/labeler@master
45+
with:
46+
use_local_config: true
47+
fail_on_error: true
1648
env:
1749
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

0 commit comments

Comments
 (0)