16
16
type : string
17
17
description : " Whether to recreate the VM"
18
18
default : " false"
19
+ simulate_scheduled_run :
20
+ required : false
21
+ type : boolean
22
+ description : " Simulate a scheduled run"
23
+ default : false
24
+ schedule :
25
+ # Run at midnight UTC every day
26
+ # Purpose: This scheduled run performs regular vulnerability scans of the codebase
27
+ # and sends notifications to Slack when new critical vulnerabilities are found.
28
+ # The scan results are used to maintain security standards and address issues promptly.
29
+ - cron : ' 0 0 * * *'
19
30
20
31
jobs :
21
32
create-runner :
36
47
cancel-in-progress : true
37
48
outputs :
38
49
is_main_branch : ${{ (github.head_ref || github.ref) == 'refs/heads/main' }}
50
+ is_scheduled_run : ${{ github.event_name == 'schedule' || inputs.simulate_scheduled_run == true }}
39
51
version : ${{ steps.branches.outputs.sanitized-branch-name }}-gha.${{github.run_number}}
40
52
preview_enable : ${{ contains( steps.pr-details.outputs.pr_body, '[x] /werft with-preview') || (steps.output.outputs.with_integration_tests != '') }}
41
53
preview_name : ${{ github.head_ref || github.ref_name }}
98
110
name : Build previewctl
99
111
if : |
100
112
(needs.configuration.outputs.pr_no_diff_skip != 'true') &&
101
- (needs.configuration.outputs.preview_enable == 'true')
113
+ (needs.configuration.outputs.preview_enable == 'true') &&
114
+ (needs.configuration.outputs.is_scheduled_run != 'true')
102
115
needs : [ configuration, create-runner ]
103
116
concurrency :
104
117
group : ${{ github.ref == 'refs/heads/main' && github.run_id || github.sha }}-build-previewctl
@@ -126,7 +139,8 @@ jobs:
126
139
if : |
127
140
(needs.configuration.outputs.pr_no_diff_skip != 'true') &&
128
141
(needs.configuration.outputs.preview_enable == 'true') &&
129
- (needs.configuration.outputs.is_main_branch != 'true')
142
+ (needs.configuration.outputs.is_main_branch != 'true') &&
143
+ (needs.configuration.outputs.is_scheduled_run != 'true')
130
144
runs-on : ${{ needs.create-runner.outputs.label }}
131
145
concurrency :
132
146
group : ${{ github.ref == 'refs/heads/main' && github.run_id || github.sha }}-infrastructure
@@ -154,6 +168,8 @@ jobs:
154
168
name : Build Gitpod
155
169
needs : [ configuration, create-runner ]
156
170
runs-on : ${{ needs.create-runner.outputs.label }}
171
+ outputs :
172
+ affected_packages : ${{ steps.check_vulnerabilities.outputs.affected_packages }}
157
173
concurrency :
158
174
group : ${{ github.ref == 'refs/heads/main' && github.run_id || github.sha }}-build-gitpod
159
175
cancel-in-progress : ${{ needs.configuration.outputs.is_main_branch == 'false' }}
@@ -299,7 +315,7 @@ jobs:
299
315
300
316
exit $RESULT
301
317
- name : Tag the release
302
- if : github.ref == 'refs/heads/main'
318
+ if : github.ref == 'refs/heads/main' && needs.configuration.outputs.is_scheduled_run != 'true'
303
319
run : |
304
320
git config --global user.name $GITHUB_USER
305
321
git config --global user.email $GITHUB_EMAIL
@@ -359,30 +375,49 @@ jobs:
359
375
-DpublishToNPM="${PUBLISH_TO_NPM}" \
360
376
-DnpmPublishTrigger="${NPM_PUBLISH_TRIGGER}" \
361
377
-DpublishToJBMarketplace="${PUBLISH_TO_JBPM}" \
362
- -DimageRepoBase=$IMAGE_REPO_BASE
378
+ -DimageRepoBase=$IMAGE_REPO_BASE || RESULT=$?
363
379
364
380
{
365
381
echo "leeway_sboms_dir=$sboms_dir"
366
382
echo "leeway_vulnerability_reports_dir=$scans_dir"
367
383
} >> $GITHUB_OUTPUT
368
384
369
385
cat "$scans_dir/vulnerability-summary.md" >> $GITHUB_STEP_SUMMARY
386
+
387
+ exit $RESULT
388
+ - name : Check for Critical Vulnerabilities
389
+ if : needs.configuration.outputs.is_scheduled_run == 'true'
390
+ id : check_vulnerabilities
391
+ shell : bash
392
+ run : |
393
+ # Parse vulnerability-stats.json from the scans directory
394
+ CRITICAL_PACKAGES=$(jq -r '.[] | select(.critical > 0) | "\(.name): \(.critical) critical vulnerabilities"' "${{ steps.scan.outputs.leeway_vulnerability_reports_dir }}/vulnerability-stats.json")
395
+
396
+ # If there are critical packages, list them and fail the build
397
+ if [ -n "$CRITICAL_PACKAGES" ]; then
398
+ echo "::error::Critical vulnerabilities found in the following packages:"
399
+ echo "$CRITICAL_PACKAGES" | tee -a $GITHUB_STEP_SUMMARY
400
+ echo "affected_packages<<EOF" >> $GITHUB_OUTPUT
401
+ echo "$CRITICAL_PACKAGES" >> $GITHUB_OUTPUT
402
+ echo "EOF" >> $GITHUB_OUTPUT
403
+ exit 1
404
+ else
405
+ echo "No critical vulnerabilities found."
406
+ fi
370
407
- name : Upload SBOMs
371
408
uses : actions/upload-artifact@v4
372
- if : success()
373
409
with :
374
410
name : sboms
375
411
path : ${{ steps.scan.outputs.leeway_sboms_dir }}
376
412
- name : Upload vulnerability reports
377
413
uses : actions/upload-artifact@v4
378
- if : success()
379
414
with :
380
415
name : vulnerability-reports
381
416
path : ${{ steps.scan.outputs.leeway_vulnerability_reports_dir }}
382
417
install-app :
383
418
runs-on : ${{ needs.create-runner.outputs.label }}
384
419
needs : [ configuration, build-gitpod, create-runner ]
385
- if : ${{ needs.configuration.outputs.is_main_branch == 'true' }}
420
+ if : ${{ needs.configuration.outputs.is_main_branch == 'true' && needs.configuration.outputs.is_scheduled_run != 'true' }}
386
421
strategy :
387
422
fail-fast : false
388
423
matrix :
@@ -421,6 +456,7 @@ jobs:
421
456
- build-gitpod
422
457
- infrastructure
423
458
- create-runner
459
+ if : needs.configuration.outputs.is_scheduled_run != 'true'
424
460
runs-on : ${{ needs.create-runner.outputs.label }}
425
461
concurrency :
426
462
group : ${{ github.ref == 'refs/heads/main' && github.run_id || github.sha }}-install
@@ -471,7 +507,7 @@ jobs:
471
507
name : " Install Monitoring Satellite"
472
508
needs : [ infrastructure, build-previewctl, create-runner ]
473
509
runs-on : ${{ needs.create-runner.outputs.label }}
474
- if : needs.configuration.outputs.with_monitoring == 'true'
510
+ if : needs.configuration.outputs.with_monitoring == 'true' && needs.configuration.outputs.is_scheduled_run != 'true'
475
511
concurrency :
476
512
group : ${{ github.ref == 'refs/heads/main' && github.run_id || github.sha }}-monitoring
477
513
cancel-in-progress : true
@@ -502,7 +538,7 @@ jobs:
502
538
runs-on : ${{ needs.create-runner.outputs.label }}
503
539
container :
504
540
image : eu.gcr.io/gitpod-core-dev/dev/dev-environment:main-gha.32399
505
- if : needs.configuration.outputs.with_integration_tests != ''
541
+ if : needs.configuration.outputs.with_integration_tests != '' && needs.configuration.outputs.is_scheduled_run != 'true'
506
542
concurrency :
507
543
group : ${{ needs.configuration.outputs.preview_name }}-integration-test
508
544
cancel-in-progress : true
@@ -532,7 +568,7 @@ jobs:
532
568
- configuration
533
569
- build-gitpod
534
570
- create-runner
535
- if : needs.configuration.outputs.is_main_branch == 'true'
571
+ if : needs.configuration.outputs.is_main_branch == 'true' && needs.configuration.outputs.is_scheduled_run != 'true'
536
572
uses : ./.github/workflows/workspace-integration-tests.yml
537
573
with :
538
574
version : ${{ needs.configuration.outputs.version }}
@@ -544,7 +580,7 @@ jobs:
544
580
- configuration
545
581
- build-gitpod
546
582
- create-runner
547
- if : needs.configuration.outputs.is_main_branch == 'true'
583
+ if : needs.configuration.outputs.is_main_branch == 'true' && needs.configuration.outputs.is_scheduled_run != 'true'
548
584
uses : ./.github/workflows/code-updates.yml
549
585
secrets : inherit
550
586
@@ -554,10 +590,31 @@ jobs:
554
590
- configuration
555
591
- build-gitpod
556
592
- create-runner
557
- if : needs.configuration.outputs.is_main_branch == 'true'
593
+ if : needs.configuration.outputs.is_main_branch == 'true' && needs.configuration.outputs.is_scheduled_run != 'true'
558
594
uses : ./.github/workflows/jetbrains-updates.yml
559
595
secrets : inherit
560
596
597
+ notify-scheduled-failure :
598
+ name : " Notify on scheduled run failure"
599
+ if : needs.configuration.outputs.is_scheduled_run == 'true' && failure()
600
+ needs :
601
+ - configuration
602
+ - build-gitpod
603
+ - workspace-integration-tests-main
604
+ - ide-code-updates
605
+ - ide-jb-updates
606
+ runs-on : ubuntu-latest
607
+ steps :
608
+ - name : Slack Notification
609
+ uses : rtCamp/action-slack-notify@v2
610
+ env :
611
+ SLACK_WEBHOOK : ${{ secrets.WORKSPACE_SLACK_WEBHOOK }}
612
+ SLACK_ICON_EMOJI : " :x:"
613
+ SLACK_USERNAME : " Scheduled Build"
614
+ SLACK_COLOR : " danger"
615
+ SLACK_MESSAGE : " ⚠️ Security Alert: Daily vulnerability scan detected critical vulnerabilities in the following packages:\n ${{ needs.build-gitpod.outputs.affected_packages }}"
616
+ SLACK_FOOTER : " <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow Logs>"
617
+
561
618
delete-runner :
562
619
if : always()
563
620
needs :
@@ -570,6 +627,7 @@ jobs:
570
627
- install
571
628
- monitoring
572
629
- integration-test
630
+ - notify-scheduled-failure
573
631
uses : gitpod-io/gce-github-runner/.github/workflows/delete-vm.yml@main
574
632
secrets :
575
633
gcp_credentials : ${{ secrets.SELF_HOSTED_GITHUB_RUNNER_GCP_CREDENTIALS }}
0 commit comments