diff --git a/.github/workflows/issue.yml b/.github/workflows/issue.yml new file mode 100644 index 0000000..1c49e44 --- /dev/null +++ b/.github/workflows/issue.yml @@ -0,0 +1,81 @@ +name: want to write + +on: + issues: + types: + - opened + +jobs: + set-label: + name: Set label + runs-on: ubuntu-22.04 + timeout-minutes: 1 + steps: + - uses: actions/github-script@v7 + with: + script: | + const issueTitle = context.payload.issue.title; + const labelsToAdd = []; + + /** + * @typedef {Object} Label + * @property {string} regex - 検索文字列 + * @property {string} label - ラベル名 + */ + /** @type {Label[]} */ + const labels = [ + { regex: /Nuxt/i, label: 'Nuxt' }, + # TODO: 面倒くさかったので一旦。優先度は高くないので気が向いたら直す + { regex: /Vue(.js)?/i, label: 'Vue.js' }, + { regex: /UnJS/i, label: 'UnJS' } + ]; + + labels.forEach(label => { + if (label.regex.test(issueTitle)) { + console.log(`Math: ${label.label}`); + labelsToAdd.push(label.label); + } + }); + + if (labelsToAdd.length > 0) { + github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: labelsToAdd + }); + } + console.info(`title: ${issueTitle}, labels: ${labelsToAdd.join(',')}`); + + # ref: https://github.com/shinGangan/.github/blob/main/.github/workflows/issue.yml + set-author: + needs: [set-label] + if: ${{ success() && contains(github.event.issue.labels.*.name, '🖐️ wish author') }} + permissions: + contents: read + issues: write + uses: shinGangan/.github/.github/workflows/issue.yml@main + with: + number: ${{ github.event.issue.number }} + assignee: ${{ github.actor }} + milestone: 'articles' + secrets: + token: ${{ secrets.COMM_GITHUB_TOKEN }} + repo: ${{ github.repository }} + + set-comment: + name: Add management comment + if: ${{ contains(github.event.issue.labels.*.name, '🙏 please write') }} + runs-on: ubuntu-22.04 + timeout-minutes: 1 + permissions: + issues: write + steps: + - run: | + gh issue edit -m 'articles' + + gh issue comment $NUMBER -b '

運営コメント

執筆希望あれば @shinGangan をメンションしてください。アサインします。' + env: + NUMBER: ${{ inputs.number }} + GH_TOKEN: ${{ secrets.COMM_GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }}