-
Notifications
You must be signed in to change notification settings - Fork 153
66 lines (55 loc) · 2.03 KB
/
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: Pull Request
on:
pull_request:
types: [opened, synchronize]
branches: [main]
jobs:
build:
uses: ./.github/workflows/reusable-build.yml
with:
bump-command: "local-bump"
branch-name: ${{ github.head_ref }}
comment:
needs: build
runs-on: ubuntu-24.04
steps:
- name: Comment PR
uses: actions/github-script@v6
with:
script: |
const version = '${{ needs.build.outputs.package-version }}'
const artifactsUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/`
const comment = `
## 🚀 Build artifacts are ready for testing!
Download the wheel file and binaries from the [workflow artifacts](${artifactsUrl}).
### Installation
**Local release:**
\`\`\`bash
pip install safety-${version}-py3-none-any.whl
\`\`\`
> Note: You need to be logged in to GitHub to access the artifacts.
`
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Build artifacts are ready for testing!')
)
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: comment
})
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
})
}