63 lines
2.1 KiB
YAML
63 lines
2.1 KiB
YAML
name: Validate Plugin PR
|
|
on:
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
validate:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout base branch (main) for validation scripts
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: main
|
|
path: base
|
|
|
|
- name: Checkout PR branch for plugin files
|
|
uses: actions/checkout@v3
|
|
with:
|
|
path: pr
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '18'
|
|
|
|
- name: Get changed files
|
|
id: changed-files
|
|
run: |
|
|
cd pr
|
|
echo "files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '^plugins/' || echo '')" >> $GITHUB_OUTPUT
|
|
|
|
- name: Block attempts to modify infrastructure
|
|
run: |
|
|
cd pr
|
|
INFRA_CHANGES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E '^\.gitea/' || echo '')
|
|
if [ -n "$INFRA_CHANGES" ]; then
|
|
echo "❌ ERROR: PRs cannot modify .gitea/ directory files"
|
|
echo "Changed infrastructure files:"
|
|
echo "$INFRA_CHANGES"
|
|
echo ""
|
|
echo "Only plugins/ directory changes are allowed."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Validate PR (using trusted validation script from main)
|
|
run: |
|
|
node base/.gitea/scripts/validate-pr.js "${{ github.event.pull_request.user.login }}" "${{ steps.changed-files.outputs.files }}"
|
|
working-directory: pr
|
|
|
|
- name: Auto-merge PR
|
|
if: success()
|
|
run: |
|
|
echo "✅ Validation passed - Auto-merging PR"
|
|
git config user.name "GitHub Actions"
|
|
git config user.email "actions@github.com"
|
|
git fetch origin ${{ github.event.pull_request.head.ref }}
|
|
git checkout main
|
|
git merge --squash origin/${{ github.event.pull_request.head.ref }}
|
|
git commit -m "${{ github.event.pull_request.title }}"
|
|
git push origin main
|
|
git push origin --delete ${{ github.event.pull_request.head.ref }}
|