-
Notifications
You must be signed in to change notification settings - Fork 48
88 lines (78 loc) · 2.39 KB
/
build-artifacts.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
name: Build Artifacts
on:
workflow_call:
inputs:
java-version:
required: true
type: string
default: '17'
run-sonar:
required: false
type: boolean
default: false
env:
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION || 'aim42' }}
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY || 'aim42_htmlSanityCheck' }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ inputs.java-version }}
- name: Cache Gradle Toolchain JDKs
uses: actions/cache@v4
with:
path: ~/.gradle/jdks
key: "${{ runner.os }}-gradle-jdks"
restore-keys: ${{ runner.os }}-jdk
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}"
restore-keys: ${{ runner.os }}-gradle
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Execute Gradle build
run: ./gradlew clean check integrationTest --scan --stacktrace
- name: Cache SonarCloud packages
uses: actions/cache@v4
if: ${{ inputs.run-sonar }}
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Analyze with SonarCloud
if: ${{ inputs.run-sonar }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
./gradlew sonar -Psonar.branch.name=${BRANCH_NAME} --info --scan
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
**/build
- name: Collect state upon failure
if: failure()
run: |
echo "Git:"
git status
echo "Env:"
env
echo "PWD:"
pwd
echo "Files:"
find * -ls