Auto Reply to Article Submission #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Reply to Article Submission | |
on: | |
issues: | |
types: | |
- opened | |
- labeled | |
jobs: | |
check-labels-and-comment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if the issue has the required labels | |
id: label-check | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const requiredLabels = ['article', 'submission']; | |
const issueLabels = context.payload.issue.labels.map(label => label.name); | |
const hasAllLabels = requiredLabels.every(label => issueLabels.includes(label)); | |
return hasAllLabels; | |
result-encoding: string | |
- name: Add comment to the issue | |
if: steps.label-check.outputs.result == 'true' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const issueCreator = context.payload.issue.user.login; | |
const comment = `Hi @${issueCreator},\n\nThanks for submitting your article! We will review it within 7 days.\n\nPlease ensure the following:\n- [ ] Your submission aligns with our goals and mission.\n- [ ] It does not market you or your company.\n\nWe will get back to you after our review!`; | |
await github.issues.createComment({ | |
...context.repo, | |
issue_number: context.payload.issue.number, | |
body: comment | |
}); | |
- name: Assign the issue to the creator | |
if: steps.label-check.outputs.result == 'true' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const issueCreator = context.payload.issue.user.login; | |
await github.issues.addAssignees({ | |
...context.repo, | |
issue_number: context.payload.issue.number, | |
assignees: [issueCreator] | |
}); |