|
1 | | -name: PR_COMMENT_CI |
| 1 | +name: pr-comment-ci |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | issue_comment: |
5 | 5 | types: [created] |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - check: |
| 8 | + call-comment: |
9 | 9 | runs-on: ubuntu-latest |
10 | | - outputs: |
11 | | - next_action: ${{ steps.get-action.outputs.next_action }} |
12 | | - if: ${{ github.event.issue.pull_request }} |
13 | 10 | steps: |
14 | | - - uses: actions/checkout@v6 |
| 11 | + - uses: pnpm/setup@fa36a5ef7dcdefc3a7cb25655c122e00cf6e636e # v3 |
15 | 12 | with: |
16 | | - repository: Tencent/tdesign |
17 | | - sparse-checkout: | |
18 | | - .github/.pr-comment-ci-whitelist |
19 | | - sparse-checkout-cone-mode: false |
| 13 | + runtime: node@22 |
| 14 | + version: v12 |
20 | 15 |
|
21 | | - - uses: actions/github-script@v7 |
22 | | - id: get-action |
23 | | - with: |
24 | | - script: | |
25 | | - const user = context.payload.comment.user.login |
26 | | - core.info(`user: ${user}`) |
27 | | -
|
28 | | - const fs = require('fs'); |
29 | | - const whitelist = fs.readFileSync('.github/.pr-comment-ci-whitelist', 'utf8'); |
30 | | -
|
31 | | - let isWhitelist = false; |
32 | | - whitelist.split('\n').forEach((owner) => { |
33 | | - if (owner === user) { |
34 | | - isWhitelist = true; |
35 | | - } |
36 | | - }); |
37 | | -
|
38 | | - let next_action = '' |
39 | | - if (isWhitelist) { |
40 | | - const body = context.payload.comment.body |
41 | | - core.info(`body: ${body}`) |
42 | | - if (body.startsWith('/update-common')) { |
43 | | - next_action='update-common' |
44 | | - } |
45 | | - if (body.startsWith('/update-snapshot')) { |
46 | | - next_action='update-snapshot' |
47 | | - } |
48 | | -
|
49 | | - if(next_action){ |
50 | | - await github.rest.reactions.createForIssueComment({ |
51 | | - owner: context.repo.owner, |
52 | | - repo: context.repo.repo, |
53 | | - comment_id: context.payload.comment.id, |
54 | | - content: 'rocket', |
55 | | - }) |
56 | | - } |
57 | | - } else { |
58 | | - core.warning('You are not collaborator'); |
59 | | - } |
60 | | - core.info(`next_action: ${next_action}`) |
61 | | - core.setOutput('next_action', next_action) |
62 | | -
|
63 | | - update-common: |
64 | | - needs: check |
65 | | - runs-on: ubuntu-latest |
66 | | - if: ${{ needs.check.outputs.next_action == 'update-common' }} |
67 | | - steps: |
68 | | - - uses: actions/checkout@v6 |
69 | | - with: |
70 | | - token: ${{ secrets.TDESIGN_BOT_TOKEN }} |
71 | | - - name: gh checkout pr |
72 | | - env: |
73 | | - GH_TOKEN: ${{ secrets.TDESIGN_BOT_TOKEN }} |
74 | | - run: gh pr checkout ${{ github.event.issue.number }} --recurse-submodules |
75 | | - - run: git submodule update --remote --merge |
76 | | - - name: Commit Common |
77 | | - run: | |
78 | | - git add . |
79 | | - git config --local user.email "github-actions[bot]@users.noreply.github.com" |
80 | | - git config --local user.name "github-actions[bot]" |
81 | | - git commit -m "chore: update common" |
82 | | - git push |
83 | | -
|
84 | | - update-snapshot: |
85 | | - needs: check |
86 | | - runs-on: ubuntu-latest |
87 | | - if: ${{ needs.check.outputs.next_action == 'update-snapshot' }} |
88 | | - steps: |
89 | | - - uses: actions/checkout@v6 |
| 16 | + - uses: TDesignOteam/tdesign-pr-trigger-action@main |
90 | 17 | with: |
91 | 18 | token: ${{ secrets.TDESIGN_BOT_TOKEN }} |
92 | | - |
93 | | - - name: gh checkout pr |
94 | | - env: |
95 | | - GH_TOKEN: ${{ secrets.TDESIGN_BOT_TOKEN }} |
96 | | - run: gh pr checkout ${{ github.event.issue.number }} --recurse-submodules |
97 | | - |
98 | | - - name: bot commtent |
99 | | - id: bot-comment |
100 | | - uses: actions/github-script@v7 |
101 | | - with: |
102 | | - script: | |
103 | | - const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` |
104 | | - const urlLink = `[Open](${url})` |
105 | | - const { data: comment } = await github.rest.issues.createComment({ |
106 | | - issue_number: context.issue.number, |
107 | | - owner: context.repo.owner, |
108 | | - repo: context.repo.repo, |
109 | | - body: `⏳ 正在运行快照更新。。。 CI: ${urlLink}` |
110 | | - }) |
111 | | - return comment.id |
112 | | -
|
113 | | - - uses: pnpm/action-setup@v4 |
114 | | - |
115 | | - - uses: actions/setup-node@v6 |
116 | | - with: |
117 | | - node-version-file: .node-version |
118 | | - |
119 | | - - run: pnpm install |
120 | | - |
121 | | - - run: npm run test:snap-update |
122 | | - |
123 | | - - name: Commit Snapshot |
124 | | - run: | |
125 | | - git add . |
126 | | - git config --local user.email "github-actions[bot]@users.noreply.github.com" |
127 | | - git config --local user.name "github-actions[bot]" |
128 | | - git commit -m "chore: update snapshot" |
129 | | - git push |
0 commit comments