mirror of
https://github.com/apple/container.git
synced 2026-08-24 10:05:43 -05:00
Added the split method for labeler workflow (#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
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
cli:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 'Sources/CLI/**'
|
||||
- 'Sources/ContainerCommands/**'
|
||||
@@ -0,0 +1,26 @@
|
||||
name: PR Label Analysis
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze PR for labeling
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Save PR metadata
|
||||
run: |
|
||||
mkdir -p ./pr-metadata
|
||||
echo "${{ github.event.pull_request.number }}" > ./pr-metadata/pr-number.txt
|
||||
|
||||
- name: Upload PR metadata as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: pr-metadata-${{ github.event.pull_request.number }}
|
||||
path: pr-metadata/
|
||||
retention-days: 1
|
||||
@@ -0,0 +1,55 @@
|
||||
name: PR Label Apply
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["PR Label Analysis"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
apply-labels:
|
||||
name: Apply labels to PR
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download PR metadata artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
pattern: pr-metadata-*
|
||||
merge-multiple: false
|
||||
continue-on-error: true
|
||||
id: download-artifact
|
||||
|
||||
- name: Read PR number
|
||||
id: pr-number
|
||||
run: |
|
||||
METADATA_DIR=$(find . -type d -name "pr-metadata-*" 2>/dev/null | head -n 1)
|
||||
|
||||
if [ -z "$METADATA_DIR" ]; then
|
||||
echo "No metadata found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PR_NUMBER=$(cat "${METADATA_DIR}/pr-number.txt")
|
||||
echo "number=${PR_NUMBER}" >> $GITHUB_OUTPUT
|
||||
echo "PR Number: ${PR_NUMBER}"
|
||||
|
||||
- name: Apply labels using labeler
|
||||
uses: actions/labeler@v5
|
||||
with:
|
||||
pr-number: ${{ steps.pr-number.outputs.number }}
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
configuration-path: .github/labeler.yml
|
||||
sync-labels: true
|
||||
Reference in New Issue
Block a user