Skip to content

Docs site dev

Docs site dev #1975

name: Pull Request Next Release
on:
issue_comment:
jobs:
next-version:
name: Next Version
runs-on: ubuntu-latest
# 在 pull request 评论触发的 issue_comment 事件中执行
if: |
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/publish')
strategy:
matrix:
node-version: [18.x]
steps:
# 判断用户是否有写权限
- name: 'Check if user has write access'
uses: 'lannonbr/[email protected]'
with:
permission: 'write'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch
- run: |
echo "HEAD_SHA=${{steps.comment-branch.outputs.head_sha}}" >> $GITHUB_ENV
# Checkout 到 PR 对应分支
- uses: actions/checkout@v2
if: success()
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- uses: actions/github-script@v6
id: run-check-suite
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const script = require('./scripts/github/createPrNextCheckSuite.js')
return await script({github, context, core, status: 'start'})
- run: |
echo "CHECK_RUN_ID=${{steps.run-check-suite.outputs.result}}" >> $GITHUB_ENV
# 安装依赖并构建
- name: Install dependencies & Build
run: |
npm i
- name: Publish version
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
node ./scripts/publishInCI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
DIST_TAG: 'alpha'
- name: Set Current Version
if: success()
run: |
DIST_VERSION=$(node -p 'require("./package.json").version')
echo "DIST_VERSION=${DIST_VERSION}" >> $GITHUB_ENV
# 发布失败后,更新 checkRun 状态
- uses: actions/github-script@v6
if: failure()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const script = require('./scripts/github/createPrNextCheckSuite.js')
return await script({github, context, core, status: 'end'})
# 发布完成后,在 issue 中评论,并更新 checkRun 状态
- uses: actions/github-script@v6
if: success()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const script = require('./scripts/github/createIssueCommentPrNextResult.js')
return await script({github, context, core})