Repository navigation
44 lines (44 loc) · 1.76 KB
/
Copy pathUpdateToRelease.yml
File metadata and controls
44 lines (44 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 }}