-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (110 loc) · 3.83 KB
/
build-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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Build and Comment on Pull Request
on:
pull_request_target:
types: [opened, reopened, synchronize]
branches:
- '*'
paths-ignore:
- 'README'
- 'README.md'
- 'LICENSE'
- 'LICENSE.md'
concurrency:
group: '${{ github.workflow }}-${{ github.head_ref }}'
cancel-in-progress: false
permissions:
issues: write
pull-requests: write
jobs:
build-and-comment:
runs-on: ubuntu-latest
outputs:
comment_id: ${{ steps.comment.outputs.comment-id }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Find comment
uses: peter-evans/find-comment@v2
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- workflow comment -->'
- name: Post/Update comment
uses: peter-evans/create-or-update-comment@v3
id: comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body-path: '.github/assets/build-pr.md'
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: |
8
16
17
21
- name: Grant execute permissions for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build --no-daemon
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: build
path: |
build/libs/*.jar
versions/*/build/libs/*.jar
if-no-files-found: error
- name: Render Markdown Template
id: render
uses: chuhlomin/[email protected]
env:
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}"
ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}"
ARTIFACT_EXPIRE_DATE: "${{ env.ARTIFACT_EXPIRE_DATE }}"
HEAD_SHA: "${{ env.HEAD_SHA }}"
with:
template: './.github/assets/build-pr-success.md'
vars: |
commit: ${{ env.HEAD_SHA }}
logs: ${{ env.JOB_PATH }}
download: ${{ env.ARTIFACT_URL }}
expire: ${{ env.ARTIFACT_EXPIRE_DATE }}
- name: Post/Update comment
uses: peter-evans/create-or-update-comment@v3
id: comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: ${{ steps.template.outputs.result }}
comment-if-failed:
needs: [build-and-comment]
if: failure()
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Render Markdown template
id: render
uses: chuhlomin/render-template@b7365ae850d49de8fbbc9af02f333f0150bdcc59
with:
template: './.github/assets/pr-comments/failed.md'
vars: |
commit: ${{ github.event.pull_request.head.sha }}
logs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Update comment (Failure)
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ needs.build-and-comment.outputs.comment_id }}
edit-mode: replace
body: ${{ steps.render.outputs.result }}