- Replace actions/checkout@v4 with https://code.forgejo.org/actions/checkout@v4 - Replace aws-actions/configure-aws-credentials@v4 with Forgejo mirror - Replace GitHub CLI (gh) with tea CLI for PR creation - Remove GITHUB_TOKEN dependency in favor of tea authentication - Ensure full compatibility with Forgejo Actions ecosystem Updated workflows: - ci.yml - deploy-scripts.yml - release.yml - code-quality.yml - pr-labeler.yml - dependency-review.yml 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
110 lines
No EOL
3.8 KiB
YAML
110 lines
No EOL
3.8 KiB
YAML
name: PR Labeler
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, edited, synchronize]
|
|
|
|
jobs:
|
|
label:
|
|
runs-on: self-hosted
|
|
name: Label Pull Request
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: https://code.forgejo.org/actions/checkout@v4
|
|
|
|
- name: Analyze and label PR
|
|
run: |
|
|
echo "Analyzing PR for automatic labeling..."
|
|
|
|
# Get changed files
|
|
git fetch origin main
|
|
# Try different approaches to get the diff
|
|
if git merge-base origin/main HEAD >/dev/null 2>&1; then
|
|
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
|
|
else
|
|
# Fallback: compare with origin/main directly
|
|
CHANGED_FILES=$(git diff --name-only origin/main HEAD || echo "")
|
|
fi
|
|
|
|
if [ -z "$CHANGED_FILES" ]; then
|
|
echo "Unable to determine changed files, using all files in current branch"
|
|
CHANGED_FILES=$(find . -name "*.ts" -o -name "*.js" -o -name "*.scss" -o -name "*.json" | grep -v node_modules | head -20)
|
|
fi
|
|
|
|
# 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\"" |