[New game]: The simon Game #66
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: Add Tags to Issues | |
on: | |
issues: | |
types: | |
- opened | |
jobs: | |
add-tags: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: Add tags to issues | |
uses: actions/github-script@v4 | |
with: | |
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
script: | | |
const { issue } = context.payload; | |
const { owner, repo } = context.repo; | |
const { title, body } = issue; | |
let tagsToAdd = []; | |
// Check if issue text contains "Documentation Bug" | |
if (body && body.toLowerCase().includes('documentation bug')) { | |
tagsToAdd.push('level1'); | |
} | |
// Check if issue title contains "Enhancement" | |
if (title && title.toLowerCase().includes('enhancement')) { | |
tagsToAdd.push('level2'); | |
} | |
// Check if issue title contains "New game" | |
if (title && title.toLowerCase().includes('new game')) { | |
tagsToAdd.push('level3'); | |
} | |
if (tagsToAdd.length > 0) { | |
// Add tags to the issue | |
await github.issues.addLabels({ | |
owner: owner, | |
repo: repo, | |
issue_number: issue.number, | |
labels: tagsToAdd | |
}); | |
console.log(`Added tags ${tagsToAdd.join(', ')} to issue #${issue.number}.`); | |
} else { | |
console.log('No tags to add.'); | |
} |