-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
206 lines (189 loc) · 7.18 KB
/
action.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: 'Build Image w/ SBT'
description: 'Build an image using sbt'
author: 'GarnerCorp'
branding:
icon: 'globe'
color: 'red'
inputs:
maven-registry:
description: "The maven registry from which to retrieve packages"
default: "https://repo.maven.apache.org/maven2/"
required: false
maven-username:
description: "Username for the maven-registry"
required: false
maven-password:
description: "Password for the maven-registry"
required: false
java-distribution:
description: "Java distribution"
default: 'temurin'
required: false
java-version:
description: "Java version to use"
default: "21"
required: false
prometheus-url:
description: "Prometheus JMX Jar URL (maven credentials will be used if from the same repository)"
required: false
working-directory:
description: "Directory containing build.sbt"
default: "."
required: false
cache-sbt-targets:
description: "Glob for sbt targets"
default: "*/target"
required: false
source-directory:
description: "Source directory within working directory"
default: "src"
required: false
copy-prometheus-to:
description: "Directories that need a prometheus jar"
default: ""
required: false
jars-to-simplify:
description: "Projects whose jar files include versions that should be stripped"
default: ""
required: false
extra-sbt-args:
description: "Extra arguments for sbt passed to build script via environment variable: EXTRA_SBT_ARGS"
default: ""
required: false
build-script:
description: "Script used to build scala project"
required: false
build-script-args:
description: "Required args for build-script"
required: false
google-credentials-json:
description: "Google Service Account JSON file"
required: false
google-cloud-sdk-version:
description: "Google Cloud SDK version"
required: false
container-project:
description: "Path within container registry for team"
required: false
skip-checkout:
description: "Use files from working directory instead of checking out"
required: false
runs:
using: 'composite'
steps:
- name: Validate inputs
if: ${{ !inputs.google-credentials-json != !inputs.google-cloud-sdk-version || !inputs.maven-username != !inputs.maven-password }}
shell: bash
env:
CODEPENDENT: '[ [ "google-cloud-sdk-version", "google-credentials-json" ], [ "maven-username", "maven-password" ] ]'
INPUTS: ${{ toJSON(inputs) }}
run: |
"$GITHUB_ACTION_PATH/../scripts/report-missing-inputs.pl"
- name: Checkout
if: ${{ ! inputs.skip-checkout }}
uses: actions/checkout@v4
- name: "Google Auth"
uses: "google-github-actions/auth@v2"
if: ${{ inputs.google-credentials-json && inputs.google-cloud-sdk-version && ! env.ACT }}
with:
credentials_json: "${{ inputs.google-credentials-json }}"
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
if: ${{ inputs.google-credentials-json && inputs.google-cloud-sdk-version && ! env.ACT }}
with:
version: ${{ inputs.google-cloud-sdk-version }}
project_id: ${{ inputs.container-project }}
- name: Configure GCloud and Docker
if: ${{ ! env.ACT }}
shell: bash
run: |
: Configure docker gcloud credential helper if it is not already configured
if [ "$(jq -r '.credHelpers["gcr.io"] // empty' ~/.docker/config.json)" = '' ] ; then
gcloud auth configure-docker
fi
- name: Install sbt
if: ${{ env.ACT }}
shell: bash
run: |
# Remove repository containing expired google key
sudo rm -f /etc/apt/sources.list.d/google-chrome.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" |
sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" |
sudo tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" |
sudo -H gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --import
sudo chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg
sudo apt-get update
sudo apt-get install -y sbt
- name: Set up JDK ${{ inputs.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java-version }}
distribution: ${{ inputs.java-distribution }}
cache: 'sbt'
- name: Find Prometheus Agent
if: inputs.prometheus-url
id: find-prometheus-agent
shell: bash
env:
PROMETHEUS_URL: ${{ inputs.prometheus-url }}
run: |
prometheus_agent=$(basename "$PROMETHEUS_URL")
echo "prometheus_agent=$prometheus_agent" >> $GITHUB_OUTPUT
- name: Cache Prometheus Agent
if: inputs.prometheus-url
id: prometheus-agent-cache
uses: actions/cache@v4
with:
key: prometheus-agent-${{ steps.find-prometheus-agent.outputs.prometheus_agent }}
restore-keys: prometheus-agent
path: ${{ inputs.working-directory }}/${{ steps.find-prometheus-agent.outputs.prometheus_agent }}
- name: Download jmx_prometheus_javaagent
if: inputs.prometheus-url && steps.prometheus-agent-cache.outputs.cache-hit != 'true'
env:
PROMETHEUS_URL: ${{ inputs.prometheus-url }}
MAVEN_USERNAME: ${{ inputs.maven-username }}
MAVEN_PASSWORD: ${{ inputs.maven-password }}
MAVEN_REGISTRY: ${{ inputs.maven-registry }}
working-directory: ${{ inputs.working-directory }}
shell: bash
run: |
if [ -n "$MAVEN_USERNAME" ] && [ -n "$MAVEN_PASSWORD" ]; then
case "$PROMETHEUS_URL" in
*"$MAVEN_REGISTRY"*)
CREDENTIALS="-u '$MAVEN_USERNAME:$MAVEN_PASSWORD'"
;;
esac
fi
curl -u "$MAVEN_USERNAME:$MAVEN_PASSWORD" -O "$PROMETHEUS_URL"
- name: Cache SBT Project
uses: actions/cache@v4
with:
key: sbt-project-${{ inputs.working-directory }}-${{ github.sha }}
restore-keys: sbt-project-${{ inputs.working-directory }}
path: ${{ inputs.working-directory }}/project/target
- name: Cache SBT Jobs
uses: actions/cache@v4
with:
key: sbt-jobs-${{ inputs.working-directory }}-${{ github.sha }}
restore-keys: sbt-jobs-${{ inputs.working-directory }}
path: ${{ inputs.working-directory }}/${{ inputs.cache-sbt-targets }}
- name: Run build
shell: bash
run: |
$GITHUB_ACTION_PATH/../scripts/add-matchers.sh
if [ -n "$BUILD_SCRIPT" ]; then
$BUILD_SCRIPT $BUILD_SCRIPT_ARGS
else
$GITHUB_ACTION_PATH/build-scala-ci.sh
fi
working-directory: ${{ inputs.working-directory }}
env:
MAVEN_USERNAME: ${{ inputs.maven-username }}
MAVEN_PASSWORD: ${{ inputs.maven-password }}
EXTRA_SBT_ARGS: ${{ inputs.extra-sbt-args }}
COPY_PROMETHEUS_TO: ${{ inputs.copy-prometheus-to }}
SIMPLIFY_PROJECT_NAMES: ${{ inputs.jars-to-simplify }}
BUILD_SCRIPT: ${{ inputs.build-script }}
BUILD_SCRIPT_ARGS: ${{ inputs.build-script-args }}