-
Notifications
You must be signed in to change notification settings - Fork 18
54 lines (48 loc) · 1.81 KB
/
create_comment.yaml
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
# This exists as a seperate workflow because pull_request workflows dont have permission to write comments
# How to use:
# 1. Add the name of the workflow that needs to leave a comment under on -> workflow_run -> workflows
# 2. In the main workflow always upload an artifact folder named comment_info
# 3. If a comment should be written then:
# 1. include issue_number.txt in the artifact folder containing the issue_number
# 2. include message.txt in the artifact folder containing the message of the comment
name: Create Comment
on:
workflow_run:
workflows: [ "Benchmarks" ]
# Cancel already running jobs
concurrency:
group: create_comment_${{ github.head_ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
upload:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 'Download results'
uses: actions/download-artifact@v4
with:
name: 'comment-info'
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- run: unzip comment_info.zip
- name: 'Comment on PR'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var fs = require('fs');
if (fs.existsSync('./issue_number.txt')) {
var issue_number = Number(fs.readFileSync('./issue_number.txt'));
var message = fs.readFileSync('./message.txt', 'utf8');
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: message,
});
}