-
Notifications
You must be signed in to change notification settings - Fork 176
77 lines (65 loc) · 2.47 KB
/
pr_artifact.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
# Creates a built artifact jar for apropriately labeled Pull Requests
name: PR Artifact
on:
pull_request:
types:
- labeled
- synchronize
# if a second commit is pushed quickly after the first, cancel the first one's build
concurrency:
group: build-artifact-${{github.head_ref}}
cancel-in-progress: true
env:
ARTIFACT_NAME: 'gregtech-dev'
NOTIFICATION_BODY: |
This Pull Request has automatic artifact deployment enabled. Download the latest build [here](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}), and extract the contents.
jobs:
Build_Artifact:
if: contains(github.event.pull_request.labels.*.name, format('deployment{0} artifact', ':'))
runs-on: ubuntu-latest
permissions:
pull-requests: write # needed to make a comment
contents: read # needed to checkout the repo if defining other permissions
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Build Project
uses: gradle/gradle-build-action@v2
with:
arguments: 'build --build-cache --no-daemon ' # disable daemon since only one gradle operation will happen
generate-job-summary: false
gradle-home-cache-includes: |
caches
jdks
notifications
wrapper
- name: Determine Artifact Name
id: artifact_name
run: |
FILE=(build/libs/*)
echo "artifact_name=${FILE[0]}" >> $GITHUB_OUTPUT
- name: Publish Artifact
uses: actions/upload-artifact@v3
with:
name: "${{env.ARTIFACT_NAME}}-${{github.head_ref}}-${{github.sha}}"
path: "${{steps.artifact_name.outputs.artifact_name}}"
if-no-files-found: error
- name: Find Existing Comment
uses: peter-evans/find-comment@v2
id: find-existing
with:
issue-number: ${{github.event.pull_request.number}}
comment-author: 'github-actions[bot]'
body-includes: 'Download the latest build [here]'
- name: Create or Update Artifact Publish Notification
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{github.event.pull_request.number}}
comment-id: ${{steps.find-existing.outputs.comment-id}}
edit-mode: replace
body: ${{env.NOTIFICATION_BODY}}