Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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/**'
65 changes: 65 additions & 0 deletions .github/workflows/color-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Color Labels
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 think we need this. We can make them by hand for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should i remvoe the colors file

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes


on:
push:
branches:
- main
paths:
- '.github/workflows/color-labels.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
create-labels:
name: Create labels with colors
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- name: Create or update labels
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = [
{ name: 'cli', color: '0E8A16', description: 'Changes to CLI components' }
];
for (const label of labels) {
try {
await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name
});
await github.rest.issues.updateLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
color: label.color,
description: label.description
});
console.log(`✅ Updated label: ${label.name}`);
} catch (error) {
if (error.status === 404) {
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
color: label.color,
description: label.description
});
console.log(`✅ Created label: ${label.name}`);
} else {
throw error;
}
}
}
console.log('🎉 All labels created/updated successfully!');
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
52 changes: 52 additions & 0 deletions .github/workflows/pr-label-apply.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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: 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