7
7
- " main"
8
8
- " rc"
9
9
- " hotfix-rc"
10
- pull_request_target :
10
+ pull_request :
11
11
types : [opened, synchronize]
12
+ workflow_call :
13
+ inputs : {}
12
14
13
15
env :
14
16
_AZ_REGISTRY : " bitwardenprod.azurecr.io"
15
17
16
18
jobs :
17
- check-run :
18
- name : Check PR run
19
- uses : bitwarden/gh-actions/.github/workflows/check-run.yml@main
20
-
21
19
lint :
22
20
name : Lint
23
21
runs-on : ubuntu-22.04
24
- needs :
25
- - check-run
26
22
steps :
27
23
- name : Check out repo
28
24
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
40
36
runs-on : ubuntu-22.04
41
37
needs :
42
38
- lint
39
+ outputs :
40
+ has_secrets : ${{ steps.check-secrets.outputs.has_secrets }}
43
41
strategy :
44
42
fail-fast : false
45
43
matrix :
75
73
base_path : ./bitwarden_license/src
76
74
node : true
77
75
steps :
76
+ - name : Check secrets
77
+ id : check-secrets
78
+ env :
79
+ AZURE_KV_CI_SERVICE_PRINCIPAL : ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
80
+ run : |
81
+ has_secrets=${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL != '' }}
82
+ echo "has_secrets=$has_secrets" >> $GITHUB_OUTPUT
83
+
78
84
- name : Check out repo
79
85
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
80
86
with :
@@ -134,6 +140,7 @@ jobs:
134
140
id-token : write
135
141
needs :
136
142
- build-artifacts
143
+ if : ${{ needs.build-artifacts.outputs.has_secrets == 'true' }}
137
144
strategy :
138
145
fail-fast : false
139
146
matrix :
@@ -227,7 +234,7 @@ jobs:
227
234
- name : Generate Docker image tag
228
235
id : tag
229
236
run : |
230
- if [[ "${GITHUB_EVENT_NAME}" == "pull_request_target " ]]; then
237
+ if [[ "${GITHUB_EVENT_NAME}" == "pull_request " ]]; then
231
238
IMAGE_TAG=$(echo "${GITHUB_HEAD_REF}" | sed "s#/#-#g")
232
239
else
233
240
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g")
@@ -289,11 +296,11 @@ jobs:
289
296
"GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
290
297
291
298
- name : Install Cosign
292
- if : github.event_name != 'pull_request_target ' && github.ref == 'refs/heads/main'
299
+ if : github.event_name != 'pull_request ' && github.ref == 'refs/heads/main'
293
300
uses : sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
294
301
295
302
- name : Sign image with Cosign
296
- if : github.event_name != 'pull_request_target ' && github.ref == 'refs/heads/main'
303
+ if : github.event_name != 'pull_request ' && github.ref == 'refs/heads/main'
297
304
env :
298
305
DIGEST : ${{ steps.build-docker.outputs.digest }}
299
306
TAGS : ${{ steps.image-tags.outputs.tags }}
@@ -322,6 +329,7 @@ jobs:
322
329
name : Upload
323
330
runs-on : ubuntu-22.04
324
331
needs : build-docker
332
+ if : ${{ needs.build-artifacts.outputs.has_secrets == 'true' }}
325
333
steps :
326
334
- name : Check out repo
327
335
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -341,7 +349,7 @@ jobs:
341
349
342
350
- name : Make Docker stubs
343
351
if : |
344
- github.event_name != 'pull_request_target '
352
+ github.event_name != 'pull_request '
345
353
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
346
354
run : |
347
355
# Set proper setup image based on branch
@@ -383,15 +391,15 @@ jobs:
383
391
384
392
- name : Make Docker stub checksums
385
393
if : |
386
- github.event_name != 'pull_request_target '
394
+ github.event_name != 'pull_request '
387
395
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
388
396
run : |
389
397
sha256sum docker-stub-US.zip > docker-stub-US-sha256.txt
390
398
sha256sum docker-stub-EU.zip > docker-stub-EU-sha256.txt
391
399
392
400
- name : Upload Docker stub US artifact
393
401
if : |
394
- github.event_name != 'pull_request_target '
402
+ github.event_name != 'pull_request '
395
403
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
396
404
uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
397
405
with :
@@ -401,7 +409,7 @@ jobs:
401
409
402
410
- name : Upload Docker stub EU artifact
403
411
if : |
404
- github.event_name != 'pull_request_target '
412
+ github.event_name != 'pull_request '
405
413
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
406
414
uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
407
415
with :
@@ -411,7 +419,7 @@ jobs:
411
419
412
420
- name : Upload Docker stub US checksum artifact
413
421
if : |
414
- github.event_name != 'pull_request_target '
422
+ github.event_name != 'pull_request '
415
423
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
416
424
uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
417
425
with :
@@ -421,7 +429,7 @@ jobs:
421
429
422
430
- name : Upload Docker stub EU checksum artifact
423
431
if : |
424
- github.event_name != 'pull_request_target '
432
+ github.event_name != 'pull_request '
425
433
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
426
434
uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
427
435
with :
@@ -550,7 +558,7 @@ jobs:
550
558
self-host-build :
551
559
name : Trigger self-host build
552
560
if : |
553
- github.event_name != 'pull_request_target '
561
+ github.event_name != 'pull_request '
554
562
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
555
563
runs-on : ubuntu-22.04
556
564
needs :
@@ -585,7 +593,7 @@ jobs:
585
593
586
594
trigger-k8s-deploy :
587
595
name : Trigger k8s deploy
588
- if : github.event_name != 'pull_request_target ' && github.ref == 'refs/heads/main'
596
+ if : github.event_name != 'pull_request ' && github.ref == 'refs/heads/main'
589
597
runs-on : ubuntu-22.04
590
598
needs :
591
599
- build-docker
@@ -621,7 +629,8 @@ jobs:
621
629
trigger-ee-updates :
622
630
name : Trigger Ephemeral Environment updates
623
631
if : |
624
- github.event_name == 'pull_request_target'
632
+ needs.build-artifacts.outputs.has_secrets == 'true'
633
+ && github.event_name == 'pull_request'
625
634
&& contains(github.event.pull_request.labels.*.name, 'ephemeral-environment')
626
635
runs-on : ubuntu-24.04
627
636
needs :
@@ -658,7 +667,8 @@ jobs:
658
667
name : Trigger Ephemeral Environment Sync
659
668
needs : trigger-ee-updates
660
669
if : |
661
- github.event_name == 'pull_request_target'
670
+ needs.build-artifacts.outputs.has_secrets == 'true'
671
+ && github.event_name == 'pull_request'
662
672
&& contains(github.event.pull_request.labels.*.name, 'ephemeral-environment')
663
673
uses : bitwarden/gh-actions/.github/workflows/_ephemeral_environment_manager.yml@main
664
674
with :
@@ -668,7 +678,6 @@ jobs:
668
678
pull_request_number : ${{ github.event.number }}
669
679
secrets : inherit
670
680
671
-
672
681
check-failures :
673
682
name : Check for failures
674
683
if : always()
@@ -684,7 +693,7 @@ jobs:
684
693
steps :
685
694
- name : Check if any job failed
686
695
if : |
687
- github.event_name != 'pull_request_target '
696
+ github.event_name != 'pull_request '
688
697
&& (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
689
698
&& contains(needs.*.result, 'failure')
690
699
run : exit 1
0 commit comments