-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from shinGangan/chore/add-workflows
chore(ci): add GitHub actions workflow
- Loading branch information
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 '<h3>運営コメント</h3>執筆希望あれば @shinGangan をメンションしてください。アサインします。' | ||
env: | ||
NUMBER: ${{ inputs.number }} | ||
GH_TOKEN: ${{ secrets.COMM_GITHUB_TOKEN }} | ||
GH_REPO: ${{ github.repository }} |