-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (83 loc) · 2.88 KB
/
build.yaml
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
name: Build and Publish Libraries
on:
push:
branches:
- main
- fix-workflows
pull_request:
workflow_dispatch: # Allow manual trigger
inputs:
forcePublish:
description: 'Force publish snapshots of libraries to Artifactory even if not main branch'
type: boolean
default: 'false' # boolean values are actually strings
required: false
env:
ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL }}
jobs:
build:
runs-on: self-hosted
env:
AWS_REGION: ${{ vars.AWS_REGION }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: '7.2'
- name: Set env vars from AWS params
uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
with:
params: |
ARTIFACTORY_URL=/artifactory/url
ARTIFACTORY_USER=/artifactory/user
ARTIFACTORY_PASSWORD=/artifactory/password
SONAR_HOST_URL=/sonarqube/url
SONAR_TOKEN=/sonarqube/token
- name: Build and test libraries
run: gradle clean test --info -b build.gradle
- name: Build JARs
run: gradle jar --info -b build.gradle
- name: SonarQube Analysis
run: |
gradle sonarqube \
-Dsonar.projectKey=ab2d-lib-project \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_TOKEN
- name: Quality Gate
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
with:
scanMetadataReportFile: build/sonar/report-task.txt
timeout-minutes: 10
- name: Generate SBOM
run: gradle cyclonedxBom
- name: Publish libraries from main branch
if: github.ref == 'refs/heads/main'
run: |
# Check for artifacts to deploy
versionPublishedList=$(SUPPRESS_LOGGING_BRANCH_CLASSIFIER=true gradle -q lookForArtifacts)
deployScript=""
for entry in $(echo "$versionPublishedList" | tr "'''" "\n"); do
buildName=$(echo "$entry" | cut -d":" -f1)
isPublished=$(echo "$entry" | cut -d":" -f2)
if [ "$isPublished" == "false" ]; then
echo "Deploying $buildName"
deployScript+="$buildName:artifactoryPublish "
fi
done
if [ "$deployScript" != "" ]; then
echo "deployScript = $deployScript"
#gradle $deployScript -b build.gradle
else
echo "No artifacts to publish."
fi
- name: Force publish libraries
if: inputs.forcePublish == 'true'
run: gradle artifactoryPublish -b build.gradle