name: "Update issues" on: issues: types: [opened] pull_request_target: types: [opened] permissions: issues: write pull-requests: write jobs: comment: runs-on: ubuntu-latest steps: - uses: actions/github-script@v9 with: script: | const item = context.payload.issue || context.payload.pull_request; // Close on sight anything opened by a user on the wiki Blacklist // page (maintained by the Wiki Guard workflow). let blacklist = []; try { const res = await fetch(`https://raw.githubusercontent.com/wiki/${context.repo.owner}/${context.repo.repo}/Blacklist.md`); if (res.ok) { blacklist = (await res.text()).split("\n") .filter(l => l.startsWith("- ")) .map(l => l.slice(2).trim().toLowerCase()) .filter(Boolean); } } catch (e) { core.warning(`Failed to fetch the blacklist: ${e}`); } if (blacklist.includes(item.user.login.toLowerCase())) { if (context.payload.pull_request) { await github.rest.pulls.update({ owner: context.repo.owner, repo: context.repo.repo, pull_number: item.number, state: "closed" }); } else { await github.rest.issues.update({ owner: context.repo.owner, repo: context.repo.repo, issue_number: item.number, state: "closed", state_reason: "not_planned" }); } return; } if (context.payload.pull_request) { return; } const issue = context.payload.issue; if (issue.title.startsWith("blacklist:") || issue.title.startsWith("revert:")) { // Handled by the Blacklist / Revert Command workflows. return; } if (/^report\s+(bugs?|issues?)\b/i.test(issue.title)) { // Tracking issue for a third-party dns/deploy/notify api: // no upgrade boilerplate; assign it to the opener and label it. await github.rest.issues.addAssignees({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, assignees: [issue.user.login] }); await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, labels: ["3rd party api"] }); return; } await github.rest.issues.createComment({ issue_number: issue.number, owner: context.repo.owner, repo: context.repo.repo, body: "Please upgrade to the latest code and try again first. Maybe it's already fixed. ```acme.sh --upgrade``` If it's still not working, please provide the log with `--debug 2`, otherwise, nobody can help you." })