Files
a0-plugins/scripts/comment_validation_failure.js
frdel 0d1291c1f2 Add auto-close PRs and discussions workflows
Add two GitHub Actions and companion scripts to automate repository maintenance: a daily workflow to close open PRs that have failing checks and no activity for 7+ days (.github/workflows/close-inactive-prs.yml + scripts/close_inactive_failing_prs.py), and a workflow to ensure Discussions exist for plugins when plugins are added/changed (.github/workflows/ensure-plugin-discussions.yml + scripts/ensure_plugin_discussions.py). Update validation comment (scripts/comment_validation_failure.js) and README to warn that inactive, repeatedly failing PRs may be auto-closed.
2026-02-24 09:40:46 +01:00

26 lines
1015 B
JavaScript

const fs = require('fs');
async function run({ github, context }) {
const marker = '<!-- a0-plugins-validation -->';
const raw = fs.readFileSync('validation.log', 'utf8');
const max = 60000;
const text = raw.length > max ? raw.slice(0, max) + '\n... (truncated)\n' : raw;
const body = `${marker}\n## ❌ Plugin submission validation failed\n\n\`\`\`\n${text}\n\`\`\`\n\nPush an update to this PR to re-run validation.\n\nIf this PR keeps failing checks and has no activity for 7+ days, it may be automatically closed.`;
const { owner, repo } = context.repo;
const issue_number = context.payload.pull_request.number;
console.log(`Commenting on PR #${issue_number} in ${owner}/${repo}`);
const res = await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
console.log(`Created validation comment: id=${res.data.id} url=${res.data.html_url}`);
return { action: 'created', comment_id: res.data.id, url: res.data.html_url };
}
module.exports = { run };