-
Notifications
You must be signed in to change notification settings - Fork 845
338 lines (293 loc) · 12.5 KB
/
platform-ci.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
330
331
332
333
334
335
336
337
338
# v3.800.10
# https://virtocommerce.atlassian.net/browse/VCST-1738
name: Platform CI
on:
workflow_dispatch:
inputs:
forceLatest:
description: "Flag to set dev-linux-latest flag on workflow_dispatch event. Allowed values true or false."
required: false
type: boolean
default: false
push:
paths-ignore:
- '.github/**'
- 'docs/**'
- 'build/**'
- 'README.md'
- 'LICENSE'
- '**/argoDeploy.json'
- '**/cloudDeploy.json'
branches: [ master, dev ]
pull_request:
paths-ignore:
- '.github/**'
- 'docs/**'
- 'build/**'
- 'README.md'
- 'LICENSE'
- '**/argoDeploy.json'
- '**/cloudDeploy.json'
jobs:
ci:
if: ${{ github.actor != 'dependabot[bot]' &&
(github.event.pull_request.head.repo.full_name == github.repository ||
github.event.pull_request.head.repo.full_name == '') }} # Check that PR not from forked repo and not from Dependabot
runs-on: ubuntu-20.04
env:
CLOUD_INSTANCE_BASE_URL: ${{secrets.CLOUD_INSTANCE_BASE_URL}}
CLIENT_ID: ${{secrets.CLIENT_ID}}
CLIENT_SECRET: ${{secrets.CLIENT_SECRET}}
SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
NUGET_KEY: ${{ secrets.NUGET_KEY }}
BLOB_SAS: ${{ secrets.BLOB_TOKEN }}
PUBLISH_TO_DOCKER: 'true'
UPDATE_LATEST_TAG: 'true'
VERSION_SUFFIX: ''
IMAGE_NAME: 'platform'
PACKAGE_SERVER: 'ghcr.io'
BUILD_STATE: 'failed'
RELEASE_STATUS: 'false'
BUILD_DOCKER: 'false'
DOCKER_TAG: 'dev-linux-latest'
MSBuildEnableWorkloadResolver: 'false'
outputs:
artifactUrl: ${{ steps.artifactUrl.outputs.DOCKER_URL }}
jira-keys: ${{ steps.jira_keys.outputs.jira-keys }}
version: ${{ steps.image.outputs.shortVersion }}
tag: ${{ env.DOCKER_TAG }}
matrix: ${{ steps.deployment-matrix.outputs.matrix }}
run-e2e: ${{ steps.run-e2e.outputs.result }}
steps:
- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set variables
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "PUBLISH_TO_DOCKER=false" >> $GITHUB_ENV
echo "UPDATE_LATEST_TAG=${{ github.event.inputs.forceLatest }}" >> $GITHUB_ENV
- name: Set RELEASE_STATUS
if: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && github.event_name == 'push' }}
run: |
echo "RELEASE_STATUS=true" >> $GITHUB_ENV
- name: Set BUILD_DOCKER
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/dev-dockerenv' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/master') || (github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main') }}
run: |
echo "BUILD_DOCKER=true" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install VirtoCommerce.GlobalTool
uses: VirtoCommerce/vc-github-actions/setup-vcbuild@master
- name: Install dotnet-sonarscanner
run: dotnet tool install --global dotnet-sonarscanner
- name: Get Image Version
uses: VirtoCommerce/vc-github-actions/get-image-version@master
id: image
- name: Get changelog
id: changelog
uses: VirtoCommerce/vc-github-actions/changelog-generator@master
- name: Set VERSION_SUFFIX variable
run: |
if [ '${{ github.event_name }}' = 'workflow_dispatch' ]; then
echo "VERSION_SUFFIX=${{ steps.image.outputs.fullSuffix }}" >> $GITHUB_ENV
else
echo "VERSION_SUFFIX=${{ steps.image.outputs.suffix }}" >> $GITHUB_ENV
fi;
- name: Set DOCKER_TAG variable
run: |
if [ '${{ github.ref }}' = 'refs/heads/master' ] || [ '${{ github.ref }}' = 'refs/heads/main' ]; then
echo "DOCKER_TAG=${{ steps.image.outputs.shortVersion }}" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ steps.image.outputs.taggedVersion }}" >> $GITHUB_ENV
fi;
- name: Add version suffix
if: ${{ github.ref != 'refs/heads/master' || github.ref != 'refs/heads/main' }}
uses: VirtoCommerce/vc-github-actions/add-version-suffix@master
with:
versionSuffix: ${{ env.VERSION_SUFFIX }}
- name: SonarCloud Begin
uses: VirtoCommerce/vc-github-actions/sonar-scanner-begin@master
- name: Build
run: vc-build Compile
- name: Unit Tests
run: vc-build Test -skip
- name: BUILD_STATE::successful
if: success()
run: echo "BUILD_STATE=successful" >> $GITHUB_ENV
- name: SonarCloud End
uses: VirtoCommerce/vc-github-actions/sonar-scanner-end@master
- name: Quality Gate
uses: VirtoCommerce/vc-github-actions/sonar-quality-gate@master
with:
login: ${{secrets.SONAR_TOKEN}}
- name: Packaging
run: vc-build Compress -skip Clean+Restore+Compile+Test
- name: Build Docker Image
if: ${{ env.BUILD_DOCKER == 'true' }}
id: dockerBuild
uses: VirtoCommerce/vc-github-actions/build-docker-image@master
with:
tag: ${{ env.DOCKER_TAG }}
imageName: 'platform'
dockerFiles: 'https://raw.githubusercontent.com/VirtoCommerce/vc-docker/feat/net8/linux/platform/Dockerfile;https://raw.githubusercontent.com/VirtoCommerce/vc-docker/master/linux/platform/wait-for-it.sh'
- name: Docker Login
if: ${{ env.BUILD_DOCKER == 'true' }}
uses: docker/login-action@v3
with:
registry: ${{ env.PACKAGE_SERVER }}
username: $GITHUB_ACTOR
password: ${{ secrets.GITHUB_TOKEN }}
- name: Swagger validation
uses: VirtoCommerce/vc-github-actions/docker-env@master
if: ${{ github.ref == 'refs/heads/dev' }}
with:
githubUser: ${{ env.GITHUB_ACTOR }}
githubToken: ${{ env.GITHUB_TOKEN }}
platformDockerTag: ${{ env.DOCKER_TAG }}
storefrontDockerTag: dev-linux-latest
platformImage: ${{ env.PACKAGE_SERVER }}/virtocommerce/platform
storefrontImage: ${{ env.PACKAGE_SERVER }}/virtocommerce/storefront
installSampleData: 'false'
- name: Publish Nuget
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
uses: VirtoCommerce/vc-github-actions/publish-nuget@master
- name: Publish to Blob
if: ${{ github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && (github.ref != 'refs/heads/master' || github.ref != 'refs/heads/main')) }}
id: blobRelease
uses: VirtoCommerce/vc-github-actions/publish-blob-release@master
with:
blobSAS: ${{ secrets.BLOB_TOKEN }}
blobUrl: ${{ vars.BLOB_URL }}
- name: Set artifactUrl value
id: artifactUrl
run: |
echo "DOCKER_URL=${{ env.PACKAGE_SERVER }}/${{github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}" >> $GITHUB_OUTPUT
echo "BLOB_URL=${{ steps.blobRelease.outputs.packageUrl }}" >> $GITHUB_OUTPUT
- name: Add Jira link
if: ${{ github.event_name == 'pull_request' }}
uses: VirtoCommerce/vc-github-actions/publish-jira-link@master
with:
branchName: ${{ github.head_ref }}
repoOrg: ${{ github.repository_owner }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add link to PR
if: ${{ github.event_name == 'pull_request' }}
uses: VirtoCommerce/vc-github-actions/publish-artifact-link@master
with:
artifactUrl: ${{ steps.artifactUrl.outputs.DOCKER_URL }}
repoOrg: ${{ github.repository_owner }}
downloadComment: 'Image tag:'
- name: Publish Github Release
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
with:
changelog: ${{ steps.changelog.outputs.changelog }}
organization: ${{ github.repository_owner }}
uses: VirtoCommerce/vc-github-actions/publish-github-release@master
- name: Create deployment matrix
if: ${{ github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
uses: VirtoCommerce/vc-github-actions/cloud-create-deploy-matrix@master
id: deployment-matrix
with:
deployConfigPath: 'cloudDeploy.json'
releaseBranch: 'master'
- name: Check commit message for version number
id: run-e2e
run: |
if [[ "${{ github.event.head_commit.message }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]];
then
echo "result=false" >> $GITHUB_OUTPUT
else
echo "result=true" >> $GITHUB_OUTPUT
fi
- name: Publish Docker Image
if: ${{ env.BUILD_DOCKER == 'true' }}
uses: VirtoCommerce/vc-github-actions/publish-docker-image@master
with:
image: ${{ steps.dockerBuild.outputs.imageName }}
tag: ${{ env.DOCKER_TAG }}
docker_user: ${{ secrets.DOCKER_USERNAME }}
docker_token: ${{ secrets.DOCKER_TOKEN }}
docker_hub: ${{ env.PUBLISH_TO_DOCKER }}
update_latest: ${{ env.UPDATE_LATEST_TAG }}
- name: Parse Jira Keys from All Commits
uses: VirtoCommerce/vc-github-actions/get-jira-keys@master
if: always()
id: jira_keys
with:
release: ${{ env.RELEASE_STATUS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push Build Info to Jira
if: ${{ env.CLOUD_INSTANCE_BASE_URL != 0 && env.CLIENT_ID != 0 && env.CLIENT_SECRET != 0 && steps.jira_keys.outputs.jira-keys != '' && always() }}
id: push_build_info_to_jira
uses: VirtoCommerce/jira-upload-build-info@master
with:
cloud-instance-base-url: '${{ secrets.CLOUD_INSTANCE_BASE_URL }}'
client-id: '${{ secrets.CLIENT_ID }}'
client-secret: '${{ secrets.CLIENT_SECRET }}'
pipeline-id: '${{ github.repository }} ${{ github.workflow }}'
build-number: ${{ github.run_number }}
build-display-name: 'Workflow: ${{ github.workflow }} (#${{ github.run_number }})'
build-state: '${{ env.BUILD_STATE }}'
build-url: '${{github.event.repository.url}}/actions/runs/${{github.run_id}}'
update-sequence-number: '${{ github.run_id }}'
last-updated: '${{github.event.head_commit.timestamp}}'
issue-keys: '${{ steps.jira_keys.outputs.jira-keys }}'
commit-id: '${{ github.sha }}'
repo-url: '${{ github.event.repository.url }}'
build-ref-url: '${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}'
- name: Confirm Jira Build Output
if: success()
run: |
echo "Jira Upload Build Info response: ${{ steps.push_build_info_to_jira.outputs.response }}"
platform-katalon-tests:
needs: 'ci'
if: ${{ ((github.ref == 'refs/heads/dev') && (github.event_name == 'push') && (needs.ci.outputs.run-e2e == 'true')) ||
(github.event_name == 'workflow_dispatch') || (github.base_ref == 'dev') && (github.event_name == 'pull_request') }}
uses: VirtoCommerce/.github/.github/workflows/[email protected]
with:
katalonRepo: 'VirtoCommerce/vc-quality-gate-katalon'
katalonRepoBranch: 'dev'
testSuite: 'Test Suites/Modules/Platform_collection'
installModules: 'true'
installCustomModule: 'false'
platformDockerTag: ${{ needs.ci.outputs.tag }}
storefrontDockerTag: 'dev-linux-latest'
secrets:
envPAT: ${{ secrets.REPO_TOKEN }}
katalonApiKey: ${{ secrets.KATALON_API_KEY }}
deploy-cloud:
if: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
needs: ci
uses: VirtoCommerce/.github/.github/workflows/[email protected]
with:
releaseSource: platform
platformVer: ${{ needs.ci.outputs.version }}
platformTag: ${{ needs.ci.outputs.tag }}
jiraKeys: ${{ needs.ci.outputs.jira-keys }}
argoServer: 'argo.virtocommerce.cloud'
matrix: '{"include":${{ needs.ci.outputs.matrix }}}'
secrets: inherit
owasp-scan:
if: ${{ github.ref == 'refs/heads/dev' && github.event_name == 'push' }}
runs-on: ubuntu-latest
needs:
- deploy-cloud
steps:
- name: OWASP ZAP Full Scan
uses: zaproxy/[email protected]
with:
token: ${{ secrets.REPO_TOKEN }}
target: 'https://vcptcore-dev.govirto.com'
cmd_options: '-a -d'
# allow_issue_writing: false