-
Notifications
You must be signed in to change notification settings - Fork 694
62 lines (60 loc) · 2.1 KB
/
pr_build_comment.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
name: Build Asset Comment for Pull Request
on:
workflow_run:
workflows: [Kolibri Build Assets for Pull Request]
types:
- completed
jobs:
post:
name: Add build artifact PR comment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Make text for build comment
id: comment-text
uses: actions/github-script@v7
with:
script: |
const utils = require('./.github/githubUtils.js')
return await utils.generateAssetComment(github, context)
- name: Unzip PR number artifact
run: unzip pr_number.zip
- name: Get PR number
id: pr-number
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const prNumber = Number(fs.readFileSync('./pr_number'));
return prNumber
- name: Find build comment
id: find-comment
uses: actions/github-script@v7
with:
script: |
const utils = require('./.github/githubUtils.js')
return await utils.findComment(github, context, ${{steps.pr-number.outputs.result}})
- name: Create build comment
if: ${{!steps.find-comment.outputs.result}}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: ${{steps.pr-number.outputs.result}},
owner: context.repo.owner,
repo: context.repo.repo,
body: ${{ steps.comment-text.outputs.result }}
})
- name: Update build comment
if: ${{steps.find-comment.outputs.result}}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{steps.find-comment.outputs.result}},
body: ${{ steps.comment-text.outputs.result }}
})