generated from aicore/template-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 2
66 lines (63 loc) · 2.16 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 pull request post pull request auto review
# depends on and only executes after pull_request_processor.yml is complete
on:
workflow_run:
workflows: ["Checking CLA Signature"]
types:
- completed
jobs:
one:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Print github contexts
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: |
ls
echo "GH context:"
echo "$GITHUB_CONTEXT"
- name: 'Download artifact'
uses: actions/[email protected]
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
console.log(artifacts);
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "prcontext"
})[0];
var download = await github.rest.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: |
ls
unzip pr.zip
cat ./comment
- name: 'Comment on Current Pull Request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.COMMENT_BOT_TOKEN }}
script: |
var fs = require('fs');
var issue_number = Number(fs.readFileSync('./PRNumber'));
var comment = String(fs.readFileSync('./comment'));
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: comment
});