Reorganize workflow files and names into 3 main categories: - Data: Data collection and synchronization workflows - Infrastructure: Infrastructure tasks (mirroring, forking) - Maintenance: All PR checks, labels, notifications, and maintenance tasks All workflows now have capitalized category prefixes for consistency. Also update internal workflow references to reflect new names.
114 lines
3.8 KiB
YAML
114 lines
3.8 KiB
YAML
name: "Maintenance: Auto-label PR"
|
|
|
|
# Sets labels automatically based on:
|
|
# - PR size (job: label-size)
|
|
# - File categories using .github/labeler config (job: label-category)
|
|
# - PR creation date for quarterly tracking (job: label-by-date)
|
|
# - Removes "Ready to merge" label on PR update (job: label-remove)
|
|
|
|
run-name: 'Set labels - PR #${{ github.event.pull_request.number }} ("${{ github.event.pull_request.title }}")'
|
|
|
|
on: pull_request_target
|
|
|
|
# Grant required permissions globally
|
|
permissions:
|
|
contents: read # Required for checking changed files
|
|
pull-requests: write # Required for labeling PRs
|
|
issues: write # Required for adding/removing labels
|
|
|
|
jobs:
|
|
label-remove:
|
|
name: "Remove Ready to merge"
|
|
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' }}
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout the pull request
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Check for label using GH CLI
|
|
id: check
|
|
run: |
|
|
gh pr view ${{ github.event.pull_request.number }} --json labels -q '.labels[].name' | grep -q 'Ready to merge' && echo "has_label=true" >> $GITHUB_OUTPUT || echo "has_label=false" >> $GITHUB_OUTPUT
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Remove "Ready to merge" label
|
|
if: steps.check.outputs.has_label == 'true'
|
|
uses: PauMAVA/add-remove-label-action@v1.0.3
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
add: ""
|
|
remove: "Ready to merge"
|
|
|
|
label-category:
|
|
name: "Category Labels"
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' }}
|
|
|
|
steps:
|
|
# Checks out the repository to read files for matching with labeler config
|
|
- uses: actions/checkout@v6
|
|
|
|
# Applies labels based on the .github/labeler.yml config
|
|
- uses: actions/labeler@v6
|
|
with:
|
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
|
|
label-size:
|
|
name: "Size Label"
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' }}
|
|
|
|
steps:
|
|
# Automatically adds size labels based on total changed lines
|
|
- name: Label by size
|
|
uses: pascalgn/size-label-action@v0.5.5
|
|
env:
|
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
with:
|
|
sizes: >
|
|
{
|
|
"0": "small",
|
|
"50": "medium",
|
|
"250": "large"
|
|
}
|
|
|
|
label-by-date:
|
|
name: "Date label (Quarters)"
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' }}
|
|
|
|
steps:
|
|
# Determines the label (02, 05, 08, 11) based on PR creation month
|
|
- name: Determine quarter label
|
|
env:
|
|
PR_CREATED_AT: ${{ github.event.pull_request.created_at }}
|
|
run: |
|
|
echo "PR created at: $PR_CREATED_AT"
|
|
|
|
# Extract the numeric month (e.g., 04 for April)
|
|
MONTH=$(date -d "$PR_CREATED_AT" +%m | sed 's/^0*//')
|
|
echo "Month extracted: $MONTH"
|
|
|
|
# Determine quarter-end label based on month
|
|
if [ "$MONTH" -le 2 ] || [ "$MONTH" -eq 12 ]; then
|
|
LABEL="02"
|
|
elif [ "$MONTH" -le 5 ]; then
|
|
LABEL="05"
|
|
elif [ "$MONTH" -le 8 ]; then
|
|
LABEL="08"
|
|
else
|
|
LABEL="11"
|
|
fi
|
|
|
|
# Set as environment variable for next step
|
|
echo "LABEL=${LABEL}" >> $GITHUB_ENV
|
|
|
|
# Adds the quarter label to the PR
|
|
- name: Add quarter label
|
|
uses: PauMAVA/add-remove-label-action@v1.0.3
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
add: "${{ env.LABEL }}"
|