forked from Jahia/jahia
-
Notifications
You must be signed in to change notification settings - Fork 0
330 lines (316 loc) · 13.3 KB
/
on-code-change.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
name: On Code Change
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- master
- '/feature-.*/'
- '/JAHIA-[0-9]-[0-9]-[0-9]-X-BRANCH/'
env:
TESTS_PATH: docker/docker-tests/
TARGET_BRANCH: ""
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
outputs:
jahia_version: ${{ steps.tags.outputs.jahia_version }}
image_tag: ${{ steps.tags.outputs.image_tag }}
steps:
- uses: actions/checkout@v2
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository
/root/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Save/Restore build artifacts from cache
uses: actions/cache@v3
with:
key: run-${{ github.run_id }}
path: |
./**/target/**
- name: Set environment variables from parameters
shell: bash
run: |
echo "NEXUS_USERNAME=${{ secrets.NEXUS_USERNAME }}" >> $GITHUB_ENV
echo "NEXUS_PASSWORD=${{ secrets.NEXUS_PASSWORD }}" >> $GITHUB_ENV
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Store project version
shell: bash
run: mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec > jahia.version
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5.4
- name: Determine tag
shell: bash
run: |
if [ "${{ github.event_name }}" != "pull_request" ]; then
cp jahia.version image.tag
else
echo `cat jahia.version`-"${{ steps.branch-name.outputs.current_branch}}" > image.tag
fi
- id: tags
name: Set Output variables
run: |
echo "::set-output name=jahia_version::`cat jahia.version`"
echo "::set-output name=image_tag::`cat image.tag`"
- name: Display Output variables
run: |
echo "OUTPUT: jahia_version = ${{steps.tags.outputs.jahia_version}}"
echo "OUTPUT: image_tag = ${{steps.tags.outputs.image_tag}}"
# Series of steps only executed when pushing to master or to one of the maintenance branches
- name: Build package and load all dependencies into local Maven repository
shell: bash
if: ${{ github.event_name == 'push' }}
run: |
mvn -U -ntp -s .github/maven.settings.xml -e \
-Dimage.tag=${{steps.tags.outputs.image_tag}} \
clean deploy de.qaware.maven:go-offline-maven-plugin:resolve-dependencies \
-Pgwt-production,unit-tests,docker \
-Dbamboo.buildNumber=${{ github.run_id }}
- name: Compile GWT development
shell: bash
if: ${{ github.event_name == 'push' }}
run: |
cd gwt/
mvn -U -ntp -s ../.github/maven.settings.xml -e \
-Dimage.tag=${{steps.tags.outputs.image_tag}} \
clean deploy \
-Pgwt-development \
-Dbamboo.buildNumber=${{ github.run_id }}
- uses: jahia/jahia-modules-action/docker-tags@v2
if: ${{ github.event_name == 'push' }}
with:
docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_password: ${{ secrets.DOCKERHUB_PASSWORD }}
version: ${{steps.tags.outputs.image_tag}}
repo: "jahia-core-dev"
dry-run: false
- name: Build graalvm image
shell: bash
if: ${{ github.event_name == 'push' }}
run: |
cd docker/docker-jahia-core/
mvn -U -ntp -s ../../.github/maven.settings.xml -e \
-Dimage.tag=${{steps.tags.outputs.image_tag}}-graalvm \
-Dimage.graalvm=true deploy \
-Dbamboo.buildNumber=${{ github.run_id }}
# Series of steps only executed when in a PR
- name: Build package and load all dependencies into local Maven repository
shell: bash
if: ${{ github.event_name == 'pull_request' }}
run: |
mvn -U -ntp -s .github/maven.settings.xml -e \
-Dimage.tag=${{steps.tags.outputs.image_tag}} \
clean install de.qaware.maven:go-offline-maven-plugin:resolve-dependencies \
-Pgwt-production,unit-tests,docker \
-Dbamboo.buildNumber=${{ github.run_id }}
- name: Push PR Docker image
# This is only done on PR, as master is pushed with mvn deploy in "Deploy artifacts to server repository"
shell: bash
if: ${{ github.event_name == 'pull_request' }}
run: docker push jahia/jahia-core-dev:${{steps.tags.outputs.image_tag}}
- name: Store docker image
shell: bash
run: docker save -o image.tar jahia/jahia-core-dev:${{steps.tags.outputs.image_tag}}
- uses: jahia/jahia-modules-action/slack-jahia@v2
if: ${{ failure() && github.event_name == 'push' }}
with:
job-event: "fail"
skip-docker: true
slack-webhook: ${{ secrets.SLACK_WEBHOOK_TEAM_PRODUCT_SNAPSHOTS_NOTIFICATIONS }}
- uses: actions/upload-artifact@v3
with:
name: integration-artifacts
path: image.tar
integration-tests:
name: Integration Tests (Standalone)
needs: build
runs-on: self-hosted
timeout-minutes: 45
steps:
- uses: jahia/jahia-modules-action/helper@v2
- uses: KengoTODA/actions-setup-docker-compose@main
with:
version: '1.29.2'
- uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: integration-artifacts
- name: Load docker image
shell: bash
run: |
docker load -i image.tar
- name: Prepare environment variable for Jahia Image
shell: bash
run: |
export JAHIA_IMAGE=jahia/jahia-core-dev:${{needs.build.outputs.image_tag}}
echo "JAHIA_IMAGE = ${JAHIA_IMAGE}"
echo "JAHIA_IMAGE=${JAHIA_IMAGE}" >> $GITHUB_ENV
- uses: jahia/jahia-modules-action/integration-tests@v2
with:
module_id: jahia-root
testrail_project: Jahia
tests_manifest: provisioning-manifest-build.yml
tests_path: ${{ env.TESTS_PATH }}
jahia_image: ${{ env.JAHIA_IMAGE }}
should_use_build_artifacts: false
should_skip_testrail: true
should_skip_zencrepes: true
github_artifact_name: jahia-integ-tests-${{ github.run_number }}
jahia_license: ${{ secrets.JAHIA_LICENSE_8X_FULL }}
docker_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_password: ${{ secrets.DOCKERHUB_PASSWORD }}
nexus_username: ${{ secrets.NEXUS_USERNAME }}
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
tests_report_name: Test report (Standalone)
testrail_username: ${{ secrets.TESTRAIL_USERNAME }}
testrail_password: ${{ secrets.TESTRAIL_PASSWORD }}
incident_pagerduty_api_key: ${{ secrets.INCIDENT_PAGERDUTY_API_KEY }}
incident_pagerduty_reporter_email: ${{ secrets.INCIDENT_PAGERDUTY_REPORTER_EMAIL }}
incident_pagerduty_reporter_id: ${{ secrets.INCIDENT_PAGERDUTY_REPORTER_ID }}
incident_google_spreadsheet_id: ${{ secrets.INCIDENT_GOOGLE_SPREADSHEET_ID }}
incident_google_client_email: ${{ secrets.INCIDENT_GOOGLE_CLIENT_EMAIL }}
incident_google_api_key_base64: ${{ secrets.INCIDENT_GOOGLE_PRIVATE_KEY_BASE64 }}
zencrepes_secret: ${{ secrets.ZENCREPES_WEBHOOK_SECRET }}
vulnerability-scan:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: jahia/jahia-modules-action/static-analysis@v2
with:
node_version: 14
auditci_level: critical
auditci_level_tests: critical
module_path: war/
tests_path: ${{ env.TESTS_PATH }}
skip_lint_modules: true
skip_lint_tests: true
security-scan:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Scan image
id: scan-build-sbom
uses: anchore/scan-action@v3
with:
image: jahia/jahia-core-dev:${{needs.build.outputs.image_tag}}
fail-build: false
acs-report-enable: true
- name: Print content from the SARIF file
shell: bash
run: cat ${{ steps.scan-build-sbom.outputs.sarif }} | jq -r '.runs[0].tool.driver.rules[].shortDescription.text'
- uses: actions/upload-artifact@v3
with:
name: SARIF
retention-days: 5
path: |
${{ steps.scan-build-sbom.outputs.sarif }}
sonar-analysis:
name: Sonar Analysis
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5.4
- name: Save/Restore build artifacts from cache
uses: actions/cache@v3
with:
key: run-${{ github.run_id }}
path: |
./**/target/**
- name: Set environment variables
shell: bash
run: |
echo "SONAR_URL=${{ secrets.SONAR_URL }}" >> $GITHUB_ENV
echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}" >> $GITHUB_ENV
echo "NEXUS_USERNAME=${{ secrets.NEXUS_USERNAME }}" >> $GITHUB_ENV
echo "NEXUS_PASSWORD=${{ secrets.NEXUS_PASSWORD }}" >> $GITHUB_ENV
- name: Analyze pull request with sonar
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
mvn -B -U -ntp -s .github/maven.settings.xml sonar:sonar -Dsonar.pullrequest.branch=${{ steps.branch-name.outputs.current_branch }} \
-Dsonar.pullrequest.key=${{ github.run_id }} \
-Dsonar.pullrequest.base=${{ env.TARGET_BRANCH }} \
-Dsonar.pullrequest.github.repository=${{ github.event.repository.name }}
- name: Sonar analysis
shell: bash
if: ${{ github.event_name != 'pull_request' }}
env:
DEPENDENCY_CHECK_SETTINGS: -DfailOnError=false -DskipProvidedScope=true -DskipTestScope=false
-DretireJsAnalyzerEnabled=false -DnodeAnalyzerEnabled=false -Dformats=HTML,JSON
-Dsonar.dependencyCheck.jsonReportPath=target/dependency-check-report.json
-Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html
-DdataDirectory=/home/circleci/.owasp/dependency-check-data
-DsuppressionFile=.circleci/owasp-suppressions.xml
run: |
if [[ "${{ steps.branch-name.outputs.current_branch }}" == "master" ]];
then
mvn -B -U -ntp -s .github/maven.settings.xml dependency-check:aggregate sonar:sonar \
$DEPENDENCY_CHECK_SETTINGS
else
mvn -B -U -ntp -s .github/maven.settings.xml dependency-check:aggregate sonar:sonar \
-Dsonar.branch.name=$CIRCLE_BRANCH $DEPENDENCY_CHECK_SETTINGS
fi
trigger-jahia-pack-private:
runs-on: ubuntu-latest
needs: [integration-tests, sonar-analysis, security-scan, vulnerability-scan, build]
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5.4
- name: Preparing variables for remote branch
id: exports
shell: bash
run: |
# If we are in a PR, we use master for the remote branch
# If we are not in a PR, we use the current branch for the remote branch
if [[ "${{ github.event.pull_request.head.ref }}" == "" ]]; then
echo "Currently NOT in a PR: ${{ github.event.pull_request.head.ref }}, using ${{ steps.branch-name.outputs.current_branch }} as remote branch"
echo "remote_branch=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_OUTPUT
else
echo "Currently in a PR with head: ${{ github.event.pull_request.head.ref }}, using master as remote branch"
echo "remote_branch=master" >> $GITHUB_OUTPUT
fi
- name: Call Jahia-pack-private
id: trigger-step
uses: jonas-schievink/workflow-proxy@v1
with:
workflow: do-it-all.yml
ref: ${{ steps.exports.outputs.remote_branch }}
repo: Jahia/jahia-pack-private
wait-for-completion-timeout: 2h
inputs: '{ "parent_image_tag": "${{needs.build.outputs.image_tag}}" }'
token: ${{ secrets.GH_API_TOKEN }}
- name: Get results of Jahia-pack-private
if: always()
shell: bash
run: |
echo "Jahia-pack-private workflow conclustion -> ${{ steps.trigger-step.outputs.workflow-conclusion }}"
echo "::notice title=Jahia-pack-private workflow::The following workflow has been executed: ${{ steps.trigger-step.outputs.workflow-url }} its conclusion was: ${{ steps.trigger-step.outputs.workflow-conclusion }}"