-
Notifications
You must be signed in to change notification settings - Fork 14
68 lines (64 loc) · 2.65 KB
/
build.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
# Taken from Machine_Maker's work for paper.
name: Build Pathetic
on:
push:
branches:
- production
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
jobs:
build:
# Run on all label events (won't be duplicated) or all push events or on PR syncs not from the same repo
if: (github.event_name == 'pull_request' && github.event.action == 'labeled') || github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'adopt'
- name: Configure Build
uses: actions/github-script@v6
id: determine
with:
script: |
const {owner, repo} = context.repo;
const event_name = "${{ github.event_name }}";
const event = ${{ toJSON(github.event) }};
const ref_type = "${{ github.ref_type }}";
const ref_name = "${{ github.ref_name }}";
const result = {
action: "build"
};
if (event_name === "push" && ref_type === "branch") {
const {data: pulls} = await github.rest.pulls.list({ owner, repo, head: `${owner}:${ref_name}`, state: "open" });
const pull = pulls.find((pr) => !!pr.labels.find((l) => l.name === "build-pr-jar"));
if (pull) {
result["pr"] = pull.number;
result["action"] = "jar";
core.info(`This is a push action but to a branch with an open PR with the build jar label (${JSON.stringify(result)})`);
return result;
}
} else if (event_name === "pull_request" && event.pull_request.labels.find((l) => l.name === "build-pr-jar")) {
result["pr"] = event.pull_request.number;
result["action"] = "jar";
core.info(`This is a pull request action with a build jar label (${JSON.stringify(result)})`);
return result;
}
core.info("This will not build a jar");
return result;
- name: Build Jar
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
mvn clean package
- name: Upload Example Jar
if: fromJSON(steps.determine.outputs.result).action == 'jar'
uses: actions/upload-artifact@v3
with:
name: pathetic-${{ fromJSON(steps.determine.outputs.result).pr }}
path: pathetic-example/target/pathetic-example-*-SNAPSHOT.jar