-
Notifications
You must be signed in to change notification settings - Fork 43
52 lines (48 loc) · 1.82 KB
/
02-integration-output.yml
File metadata and controls
52 lines (48 loc) · 1.82 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
name: output message
on:
workflow_call:
jobs:
ouput_message:
name: output
runs-on: ubuntu-latest
steps:
- name: download integration detail
uses: actions/download-artifact@v4
with:
name: integration-archive-${{ github.event.number }}
- name: create comment
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
const fs = require('fs');
let rawdata = fs.readFileSync('integration-${{ github.event.number }}-detail.md');
let message = rawdata.toString();
if (message.includes("CVE")) {
message += "\n @deepin-community/ci CVE detected\n"
}
const BOT_NAME = "INTEGRATION Bot"
const COMMENT_HEAD = "**" + BOT_NAME + "**\n\n"
const COMMENT_BODY = "Integration Details: " + message
const response = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
})
const reg = new RegExp("\\*+" + BOT_NAME + "\\*+")
tagBotComment= response.data.find(comment => comment.body.match(reg))
if (tagBotComment) {
await github.rest.issues.updateComment({
comment_id: tagBotComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: COMMENT_HEAD + COMMENT_BODY
})
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: COMMENT_HEAD + COMMENT_BODY
})
}