-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
54 lines (48 loc) · 1.79 KB
/
Copy pathaction.yml
File metadata and controls
54 lines (48 loc) · 1.79 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
45
46
47
48
49
50
51
52
53
54
---
name: PRune
description: Replace PR descriptions with before/after SHA and changed files
runs:
using: composite
steps:
- name: Write description
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;
const short = sha => sha.slice(0, 7);
const compareUrl = `${context.payload.repository.html_url}/compare/${pr.base.sha}...${pr.head.sha}`;
const files = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
per_page: 100,
});
const changedFiles = files
.slice(0, 20)
.map(file => `- \`${file.filename}\` ${file.status} (+${file.additions}/-${file.deletions})`);
if (files.length > 20) {
changedFiles.push(`- ${files.length - 20} more files`);
}
const newBody = [
'## Before',
`\`${pr.base.ref}\` at \`${short(pr.base.sha)}\``,
'',
'## After',
`\`${pr.head.ref}\` at \`${short(pr.head.sha)}\``,
'',
'## Changed',
changedFiles.length ? changedFiles.join('\n') : '- No file changes reported',
'',
'## Compare',
compareUrl,
'',
'---',
'<img src="https://raw.githubusercontent.com/libnudget/bot/main/assets/avatar.png" width="16" alt=""> `libnudget/prune@v1`',
].join('\n');
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
body: newBody,
});
core.info('PR #' + pr.number + ' description updated');