Skip to content

Commit

Permalink
ci: add non-bounty close action
Browse files Browse the repository at this point in the history
This commit ensures that all issues that are opened by people not in the
Livepeer organization will be closed as these are likely not Livepeer
bounties.
  • Loading branch information
rickstaa committed Jun 18, 2024
1 parent d0cb7be commit a60d6f6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/close_non_member_issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Close Non-Member Issues

on:
issues:
types: [opened, reopened]

jobs:
close_non_member_issues:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Close issue if not created by organization member or collaborator
uses: actions/github-script@v6
with:
script: |
async function run() {
const issueAuthorAssociation = context.payload.issue.author_association;
const commentBody = '> [!WARNING]\n> **Auto-closed**: Repository is for member-created bounties only.';
if (issueAuthorAssociation !== 'OWNER' && issueAuthorAssociation !== 'MEMBER' && issueAuthorAssociation !== 'COLLABORATOR') {
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botCommentExists = comments.some(comment => comment.body === commentBody);
if (!botCommentExists) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody,
});
}
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
state: 'closed',
labels: ['closed by bot'],
});
console.log(`Issue #${context.issue.number} closed because the author is not an owner, member, or collaborator.`);
}
}
run();
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
*.code-workspace

0 comments on commit a60d6f6

Please sign in to comment.