Skip to content

Commit

Permalink
Merge pull request #46 from shinGangan/chore/add-workflows
Browse files Browse the repository at this point in the history
chore(ci): add GitHub actions workflow
  • Loading branch information
shinGangan authored Jul 6, 2024
2 parents 8f7681e + c4cd978 commit 1aacf8c
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/issue.yml
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 }}

0 comments on commit 1aacf8c

Please sign in to comment.