Skip to content

Update ai plugin to v0.1.1 #33

Update ai plugin to v0.1.1

Update ai plugin to v0.1.1 #33

name: Validate Plugin TOML
on:
pull_request_target:
branches:
- master
paths:
- 'plugins/**'
permissions:
contents: read
issues: write
pull-requests: write
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Get changed plugins
id: changed
run: |
CHANGED_PLUGINS=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.event.pull_request.head.sha }} | grep '^plugins/' | cut -d'/' -f2 | sort -u | tr '\n' ' ')
echo "plugins=$CHANGED_PLUGINS" >> $GITHUB_OUTPUT
echo "Changed plugins: $CHANGED_PLUGINS"
- name: Setup Node.js
if: steps.changed.outputs.plugins != ''
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup pnpm
if: steps.changed.outputs.plugins != ''
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install dependencies
if: steps.changed.outputs.plugins != ''
run: pnpm install
- name: Validate plugin.toml files
id: validate
if: steps.changed.outputs.plugins != ''
continue-on-error: true
env:
VALIDATION_REPORT_PATH: validation-report.md
run: |
pnpm validate ${{ steps.changed.outputs.plugins }}
echo "result=success" >> $GITHUB_OUTPUT
- name: Post validation comment
if: always() && steps.changed.outputs.plugins != ''
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const marker = '<!-- plugin-toml-validation -->';
let body;
const reportPath = 'validation-report.md';
if (fs.existsSync(reportPath)) {
body = marker + '\n' + fs.readFileSync(reportPath, 'utf8');
} else {
body = marker + '\n## Plugin TOML Validation Report\n\n> No validation report generated.';
}
try {
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,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
} catch (error) {
if (error.status === 403) {
core.warning(`Skipping PR comment because the workflow token cannot write comments: ${error.message}`);
return;
}
throw error;
}
- name: Fail if validation failed
if: steps.validate.outcome == 'failure'
run: exit 1