ice/.forgejo/workflows/pr-labeler.yml
Claude Code b913475932 Add comprehensive CI/CD workflows for Forgejo Actions
- ci.yml: Complete CI pipeline with lint, type-check, tests, build, security, and i18n validation
- code-quality.yml: Advanced code analysis including complexity, TODO tracking, and import analysis
- dependency-review.yml: Automated dependency update review with security checks
- pr-labeler.yml: Intelligent PR labeling based on files and content
- release.yml: Automated release process with changelog generation
- Documentation and best practices guide

Features:
- Multi-node testing (Node 18, 20)
- Security scanning for hardcoded secrets
- Bundle size impact analysis
- Translation key validation
- Complexity analysis and code quality metrics

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-07 19:50:57 -04:00

99 lines
No EOL
3.2 KiB
YAML

name: PR Labeler
on:
pull_request:
types: [opened, edited, synchronize]
jobs:
label:
runs-on: ubuntu-latest
name: Label Pull Request
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Analyze and label PR
run: |
echo "Analyzing PR for automatic labeling..."
# Get changed files
git fetch origin main
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
# Initialize labels array
LABELS=""
# Check file types and paths
if echo "$CHANGED_FILES" | grep -q "^src/.*\.ts$"; then
LABELS="$LABELS,backend"
fi
if echo "$CHANGED_FILES" | grep -q "^src/frontend/.*\.ts$"; then
LABELS="$LABELS,frontend"
fi
if echo "$CHANGED_FILES" | grep -q "^public/.*\.\(js\|html\)$"; then
LABELS="$LABELS,frontend"
fi
if echo "$CHANGED_FILES" | grep -q "^src/scss/.*\.scss$"; then
LABELS="$LABELS,styles"
fi
if echo "$CHANGED_FILES" | grep -q "^tests/.*\.test\.ts$"; then
LABELS="$LABELS,tests"
fi
if echo "$CHANGED_FILES" | grep -q "^\.forgejo/workflows/"; then
LABELS="$LABELS,ci/cd"
fi
if echo "$CHANGED_FILES" | grep -q "package.*\.json$"; then
LABELS="$LABELS,dependencies"
fi
if echo "$CHANGED_FILES" | grep -q "^docs/\|README\.md\|CLAUDE\.md"; then
LABELS="$LABELS,documentation"
fi
if echo "$CHANGED_FILES" | grep -q "^src/i18n/"; then
LABELS="$LABELS,i18n"
fi
if echo "$CHANGED_FILES" | grep -q "^scripts/"; then
LABELS="$LABELS,tooling"
fi
# Check PR title/body for keywords
PR_TITLE="${{ github.event.pull_request.title }}"
PR_BODY="${{ github.event.pull_request.body }}"
if echo "$PR_TITLE $PR_BODY" | grep -qi "security\|vulnerability\|CVE"; then
LABELS="$LABELS,security"
fi
if echo "$PR_TITLE $PR_BODY" | grep -qi "performance\|optimize\|speed"; then
LABELS="$LABELS,performance"
fi
if echo "$PR_TITLE $PR_BODY" | grep -qi "bug\|fix\|issue"; then
LABELS="$LABELS,bug"
fi
if echo "$PR_TITLE $PR_BODY" | grep -qi "feature\|enhancement\|add"; then
LABELS="$LABELS,enhancement"
fi
if echo "$PR_TITLE $PR_BODY" | grep -qi "breaking change\|BREAKING"; then
LABELS="$LABELS,breaking-change"
fi
# Remove leading comma and duplicates
LABELS=$(echo "$LABELS" | sed 's/^,//' | tr ',' '\n' | sort -u | tr '\n' ',' | sed 's/,$//')
echo "Suggested labels: $LABELS"
# Note: In actual Forgejo/Gitea, you would use the API to apply labels
# This is just for demonstration
echo "To apply labels, use: tea pr edit ${{ github.event.pull_request.number }} --add-label \"$LABELS\""