-
-
Notifications
You must be signed in to change notification settings - Fork 166
66 lines (62 loc) · 2.07 KB
/
comment-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
name: Comment on the pull request
# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ["PR Maintenance"]
types:
- completed
jobs:
comment-stats:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request'
permissions:
pull-requests: write
steps:
- name: "Download artifact"
uses: actions/[email protected]
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: Find PR
id: find-pr
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
var fs = require('fs');
var issue_number = Number(fs.readFileSync('./NR'));
return issue_number
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
continue-on-error: true
with:
issue-number: ${{ steps.find-pr.outputs.result }}
comment-author: "github-actions[bot]"
body-includes: <!-- CI Comment -->
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.find-pr.outputs.result }}
body-file: comment.md
edit-mode: replace