108 lines
3.2 KiB
YAML
108 lines
3.2 KiB
YAML
name: PR Plugin Gate
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- '.github/workflows/**'
|
|
- 'registry.json'
|
|
- 'withdrawn.json'
|
|
- 'scripts/**'
|
|
- 'keys/**'
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
validate:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout plugins repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Check if registry has active plugins
|
|
id: reg
|
|
run: |
|
|
count=$(node -e "const r = JSON.parse(require('fs').readFileSync('registry.json','utf8')); console.log((r.plugins||[]).length)")
|
|
echo "count=$count" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Checkout Reims-Go CLI source
|
|
if: steps.reg.outputs.count != '0'
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: Nwflower/Reims-Go
|
|
ref: main
|
|
path: reims-go
|
|
|
|
- name: Setup Go from Reims-Go go.mod
|
|
if: steps.reg.outputs.count != '0'
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: reims-go/go.mod
|
|
|
|
- name: Build headless reims-go CLI
|
|
if: steps.reg.outputs.count != '0'
|
|
run: |
|
|
cd reims-go
|
|
mkdir -p cmd/reims-doctor
|
|
cat <<'EOF' > cmd/reims-doctor/main.go
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"github.com/Nwflower/reims-go/internal/cli"
|
|
)
|
|
|
|
func main() {
|
|
os.Exit(cli.Main(os.Args[1:]))
|
|
}
|
|
EOF
|
|
CGO_ENABLED=0 go build -o "$GITHUB_WORKSPACE/reims-go-cli" ./cmd/reims-doctor
|
|
|
|
- name: Validate registry & run static security gate
|
|
id: gate
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
extra=""
|
|
if [ -x "./reims-go-cli" ]; then
|
|
extra="--reims-bin ./reims-go-cli"
|
|
fi
|
|
node scripts/build-index.mjs --check $extra --report pr-report.md
|
|
|
|
- name: Post gate report comment on PR
|
|
if: always() && hashFiles('pr-report.md') != ''
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
const body = fs.readFileSync('pr-report.md', 'utf8');
|
|
const marker = '<!-- reims-go-plugin-gate -->';
|
|
const fullBody = `${marker}\n${body}`;
|
|
const { data: comments } = await github.rest.issues.listComments({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
});
|
|
const existing = comments.find((c) => c.body && c.body.includes(marker));
|
|
if (existing) {
|
|
await github.rest.issues.updateComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: existing.id,
|
|
body: fullBody,
|
|
});
|
|
} else {
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
body: fullBody,
|
|
});
|
|
}
|