Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cli:
- changed-files:
- any-glob-to-any-file:
- 'Sources/CLI/**'
- 'Sources/ContainerCommands/**'
26 changes: 26 additions & 0 deletions .github/workflows/pr-label-analysis.yml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions .github/workflows/pr-label-apply.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to have checked out the repo to access this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need to checkout the repository to access the .github/labeler.yml configuration file. Without checkout, the workflow runner won't have access to any files from the repo, including the labeler configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the repo being checked out in this workflow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I accidentally removed it let me add it again. Thank you Katie for pointing that out.

sync-labels: true