Repository navigation
Stable release 4.0.0: merge dev into master #293
This file contains hidden or 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: UpdateToRelease | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - edited | |
| branches: | |
| - master | |
| jobs: | |
| UpdateToRelease: | |
| runs-on: ubuntu-latest | |
| # 添加条件:如果是 bot 触发的则跳过,避免无限循环;fork 的 PR 拿不到 secrets,也跳过 | |
| if: github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login != 'github-actions[bot]' | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| steps: | |
| # 用 GitHub App 的 token 创建版本 PR,这样它的工作流无需手动批准就能运行并自动合并 | |
| - name: Generate a token | |
| id: generate_token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| permission-contents: write | |
| permission-pull-requests: write | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ steps.generate_token.outputs.token }} | |
| - name: Update to release | |
| run: | | |
| if [[ ${{ github.event.pull_request.head.ref }} != dev && $(git diff --name-only HEAD HEAD~1) == *XMOJ.user.js* ]]; then | |
| echo Closing PR | |
| gh pr comment ${{ github.event.pull_request.number }} --body "请向\`dev\`分支提交pull request, 本pull request将被自动关闭" | |
| gh pr close ${{ github.event.pull_request.number }} | |
| else | |
| node ./Update/UpdateToRelease.js ${{ steps.generate_token.outputs.token }} ${{ github.event.pull_request.number }} "$PR_BODY" | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| PR_BODY: ${{ github.event.pull_request.body }} |