-
Notifications
You must be signed in to change notification settings - Fork 74
54 lines (45 loc) · 1.39 KB
/
official-images-comment.yml
File metadata and controls
54 lines (45 loc) · 1.39 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: Official Images Updates Comment
on:
workflow_run:
workflows: ["Official Images Updates"]
types:
- completed
permissions:
actions: read
pull-requests: write
jobs:
comment:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: pr-comment-data
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Post comment
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
const prNumber = fs.readFileSync('pr_number.txt', 'utf8').trim();
const diff = fs.readFileSync('diff.txt', 'utf8').trim();
if (!diff) {
console.log('No diff found, skipping comment.');
return;
}
const body = `<details>
<summary>Library file diff (ignoring commit IDs)</summary>
\`\`\`diff
${diff}
\`\`\`
</details>`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(prNumber),
body: body
});