Skip to content

Commit c76e0f4

Browse files
Added the split method for labeler workflow (apple#788)
- This can basically Help teams know what changes are made in pr - Added the split approach @katiewasnothere suggested using openssf - Added additional feature for colors - Currently this is for CLI only later we can add multiple - Labeling flow - TRIGGER: Pull Request Opened (untrusted code) - READ-ONLY stage: just save job number to artifact - WRITE: load job number artifact, use GH labeler action with `labeler.yml` from repo
1 parent 87862d1 commit c76e0f4

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

.github/labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cli:
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- 'Sources/CLI/**'
5+
- 'Sources/ContainerCommands/**'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: PR Label Analysis
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
analyze:
12+
name: Analyze PR for labeling
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Save PR metadata
17+
run: |
18+
mkdir -p ./pr-metadata
19+
echo "${{ github.event.pull_request.number }}" > ./pr-metadata/pr-number.txt
20+
21+
- name: Upload PR metadata as artifact
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: pr-metadata-${{ github.event.pull_request.number }}
25+
path: pr-metadata/
26+
retention-days: 1
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: PR Label Apply
2+
3+
on:
4+
workflow_run:
5+
workflows: ["PR Label Analysis"]
6+
types:
7+
- completed
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
apply-labels:
14+
name: Apply labels to PR
15+
runs-on: ubuntu-latest
16+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
17+
permissions:
18+
contents: read
19+
pull-requests: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Download PR metadata artifact
26+
uses: actions/download-artifact@v4
27+
with:
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
run-id: ${{ github.event.workflow_run.id }}
30+
pattern: pr-metadata-*
31+
merge-multiple: false
32+
continue-on-error: true
33+
id: download-artifact
34+
35+
- name: Read PR number
36+
id: pr-number
37+
run: |
38+
METADATA_DIR=$(find . -type d -name "pr-metadata-*" 2>/dev/null | head -n 1)
39+
40+
if [ -z "$METADATA_DIR" ]; then
41+
echo "No metadata found"
42+
exit 1
43+
fi
44+
45+
PR_NUMBER=$(cat "${METADATA_DIR}/pr-number.txt")
46+
echo "number=${PR_NUMBER}" >> $GITHUB_OUTPUT
47+
echo "PR Number: ${PR_NUMBER}"
48+
49+
- name: Apply labels using labeler
50+
uses: actions/labeler@v5
51+
with:
52+
pr-number: ${{ steps.pr-number.outputs.number }}
53+
repo-token: ${{ secrets.GITHUB_TOKEN }}
54+
configuration-path: .github/labeler.yml
55+
sync-labels: true

0 commit comments

Comments
 (0)