-
Notifications
You must be signed in to change notification settings - Fork 21
84 lines (73 loc) · 2.62 KB
/
auto-respond-pr.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Auto Respond to PR
on:
pull_request:
types: [opened, synchronize, closed, ready_for_review]
jobs:
auto_respond:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: base
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: pr
fetch-depth: 0
- name: Run build script on base branch
run: |
cd base
npm install
npm run build
cd ..
- name: Run build script on PR branch
run: |
cd pr
git config --global user.email "dax@duck.com"
git config --global user.name "dax"
echo ${{ github.event.pull_request.base.ref }}
git fetch origin ${{ github.event.pull_request.base.ref }}
git rebase origin/${{ github.event.pull_request.base.ref }}
npm install
npm run build
cd ..
- name: Create diff of file outputs
run: |
node pr/.github/scripts/diff-directories.js base pr > diff.txt
- name: Find Previous Comment
uses: peter-evans/find-comment@v3
id: find_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Generated file diff'
direction: last
- name: Create Comment Body
uses: actions/github-script@v7
id: create_body
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const prNumber = context.issue.number;
const diffOut = fs.readFileSync('diff.txt', 'utf8');
const commentBody = `
### *[Beta]* Generated file diff
*Time updated:* ${new Date().toUTCString()}
${diffOut}
`;
core.setOutput('comment_body', commentBody);
core.setOutput('pr_number', prNumber);
- name: Create, or Update the Comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body: ${{ steps.create_body.outputs.comment_body }}
edit-mode: replace