File tree Expand file tree Collapse file tree 2 files changed +47
-5
lines changed
Expand file tree Collapse file tree 2 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 1010 - any-glob-to-any-file :
1111 - ' .github/workflows/*'
1212
13- # Add the `documentation` label to PRs that change any file in the `user_guide_src/source/` directory .
13+ # Add the `documentation` label to PRs for documentation only .
1414' documentation ' :
1515- changed-files :
1616 - any-glob-to-all-files :
17- - ' user_guide_src/source/*'
17+ - ' user_guide_src/source/** '
1818
19- # Add the `testing` label to PRs that change files in the ` tests/` directory ONLY .
19+ # Add the `testing` label to PRs that changes tests only .
2020' testing ' :
2121- changed-files :
2222 - any-glob-to-all-files :
23- - ' tests/*'
23+ - ' tests/** '
Original file line number Diff line number Diff line change @@ -4,16 +4,58 @@ name: Add Labels to PRs
44# in a PR, and then change it back to `pull_request_target` before merging.
55# @see https://github.com/actions/labeler?tab=readme-ov-file#updating-major-version-of-the-labeler
66on :
7- - pull_request_target
7+ - pull_request
88
99jobs :
10+ validate-source :
11+ permissions :
12+ contents : read
13+ pull-requests : read
14+ runs-on : ubuntu-24.04
15+ outputs :
16+ valid : ${{ steps.check.outputs.valid }}
17+
18+ steps :
19+ - name : Check if PR is from the main repository
20+ id : check
21+ run : |
22+ if [[ "$HEAD_REPO" == "codeigniter4/CodeIgniter4" ]]; then
23+ echo "valid=true" >> $GITHUB_OUTPUT
24+ else
25+ echo "valid=false" >> $GITHUB_OUTPUT
26+ fi
27+ env :
28+ HEAD_REPO : ${{ github.event.pull_request.head.repo.full_name }}
29+
1030 add-labels :
31+ needs : validate-source
1132 permissions :
1233 contents : read
1334 pull-requests : write
1435 runs-on : ubuntu-24.04
1536
1637 steps :
38+ - name : Checkout
39+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
40+ with :
41+ persist-credentials : false
42+
43+ - name : Verify PR source for workflow file changes
44+ run : |
45+ # Get changed files in this PR
46+ git fetch origin "refs/pull/${{ github.event.pull_request.number }}/merge"
47+ CHANGED_FILES=$(git diff --name-only origin/develop FETCH_HEAD 2>/dev/null || echo "")
48+
49+ # Check if this workflow file is being modified
50+ if echo "$CHANGED_FILES" | grep -q "\.github/workflows/label-pr\.yml"; then
51+ if [[ "$IS_VALID" != "true" ]]; then
52+ echo "::error::Changes to label-pr.yml can only be made from the main repository."
53+ exit 1
54+ fi
55+ fi
56+ env :
57+ IS_VALID : ${{ needs.validate-source.outputs.valid }}
58+
1759 - name : Add labels
1860 uses : actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1
1961 with :
You can’t perform that action at this time.
0 commit comments