Skip to content

Comment on Active Add Profile Issues #19

Comment on Active Add Profile Issues

Comment on Active Add Profile Issues #19

name: Comment on Active Add Profile Issues
on:
workflow_dispatch:
schedule:
- cron: '0 */6 * * *'
jobs:
comment-on-active-issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Get Open Issues and Comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: openIssues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
for (const issue of openIssues) {
if (issue.title.toLowerCase().includes('add profile')) {
const issueCreator = issue.user.login;
const commentMessage = `@all-contributors please add @${issueCreator} for review`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number
});
const hasAllContributorsComment = comments.some(comment =>
comment.body.includes('@all-contributors please add')
);
if (!hasAllContributorsComment) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: commentMessage
});
console.log(`Commented on issue #${issue.number}`);
} else {
console.log(`Skipped commenting on issue #${issue.number} - already has an all-contributors comment`);
}
}
}