test: test ci #14
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: PR_COMMENT_CI | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
outputs: | |
next_action: ${{ steps.get-action.outputs.next_action }} | |
if: ${{ github.event.issue.pull_request }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/github-script@v7 | |
id: get-action | |
with: | |
script: | | |
let next_action = '' | |
let isReviewer = false; | |
const user = context.payload.comment.user.login | |
core.debug(`user: ${user}`) | |
const fs = require('fs') | |
const CODEOWNERS = fs.readFileSync('.github/CODEOWNERS', 'utf8') | |
core.debug(`CODEOWNERS: ${CODEOWNERS}`) | |
CODEOWNERS.match(/@\w+/g).forEach((owner) => { | |
if (owner === `@${user}`) { | |
isReviewer = true | |
} | |
}) | |
if (isReviewer) { | |
console.log('Allowed') | |
const body = context.payload.comment.body | |
if (body.startsWith('/update-dist')) { | |
next_action='update-dist' | |
} | |
} else { | |
core.warning('You are not collaborator'); | |
} | |
core.info(`next_action: ${next_action}`) | |
core.setOutput('next_action', next_action) | |
output-next-action: | |
needs: check | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo ${{ needs.check.outputs.next_action }} | |
update-dist: | |
needs: check | |
runs-on: ubuntu-latest | |
if: ${{ needs.check.outputs.next_action == 'update-dist' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: gh checkout pr | |
env: | |
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }} | |
run: gh pr checkout ${{ github.event.issue.number }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- run: pnpm install | |
- run: pnpm build | |
- name: Commit build | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} | |
run: | | |
git add . | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -m "chore: build" | |
git push |