Repository navigation
chore(deps): bump actions/setup-node from 6 to 7 #99
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Label PRs | |
| on: | |
| pull_request: | |
| types: [opened, synchronize] | |
| permissions: {} | |
| jobs: | |
| label: | |
| name: Auto-label by path | |
| runs-on: ubuntu-latest | |
| # Fork PRs get a read-only token, so labeling cannot succeed there. | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Apply labels by changed path | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| FILES="$(gh pr diff "$PR_NUMBER" --name-only)" | |
| LABELS="" | |
| if echo "$FILES" | grep -q "^standards/"; then | |
| LABELS="$LABELS standards" | |
| fi | |
| if echo "$FILES" | grep -q "^scaffold/"; then | |
| LABELS="$LABELS scaffold" | |
| fi | |
| if echo "$FILES" | grep -q "^docs/"; then | |
| LABELS="$LABELS documentation" | |
| fi | |
| if echo "$FILES" | grep -q "^registry.json"; then | |
| LABELS="$LABELS registry" | |
| fi | |
| if echo "$FILES" | grep -q "^\.github/"; then | |
| LABELS="$LABELS ci" | |
| fi | |
| if [ -z "$LABELS" ]; then | |
| echo "No labels to apply" | |
| exit 0 | |
| fi | |
| EXISTING="$(gh label list --limit 200 --json name --jq '.[].name')" | |
| for label in $LABELS; do | |
| # Create only when missing, so existing label colors are kept. | |
| if ! printf '%s\n' "$EXISTING" | grep -qx "$label"; then | |
| gh label create "$label" --color "ededed" || true | |
| fi | |
| gh pr edit "$PR_NUMBER" --add-label "$label" | |
| done | |
| echo "Applied labels:$LABELS" |