5
5
6
6
on :
7
7
# Trigger 1: PR created on main or version branches (*.*)
8
- pull_request :
8
+ pull_request_target :
9
9
branches :
10
10
- main
11
11
- ' *.*'
@@ -36,21 +36,21 @@ jobs:
36
36
37
37
- name : Determine branches for PR events
38
38
id : determine-pr-branches
39
- if : github.event_name == 'pull_request '
39
+ if : github.event_name == 'pull_request_target '
40
40
env :
41
41
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
42
+ HEAD_REF : ${{ github.head_ref }}
42
43
run : |
43
44
# For PR events, validate base branch and use head ref if valid
44
45
base_ref="${{ github.base_ref }}"
45
- head_ref="${{ github.head_ref }}"
46
46
echo "Base branch: $base_ref"
47
- echo "Head branch: $head_ref "
47
+ echo "Head branch: $HEAD_REF "
48
48
49
49
if [[ "$base_ref" =~ ^[0-9]+\.[0-9]+$ ]] || [[ "$base_ref" == "main" ]]; then
50
50
echo "Base branch matches allowed pattern (main or digit.digit)"
51
- echo "branches=[\"$head_ref \"]" >> $GITHUB_OUTPUT
51
+ echo "branches=[\"$HEAD_REF \"]" >> $GITHUB_OUTPUT
52
52
echo "output-branch-name=$base_ref" >> $GITHUB_OUTPUT
53
- echo "Branches to scan: [$head_ref ]"
53
+ echo "Branches to scan: [$HEAD_REF ]"
54
54
echo "Output files will use branch name: $base_ref"
55
55
else
56
56
echo "Base branch does not match allowed pattern - no branches to scan"
@@ -60,17 +60,17 @@ jobs:
60
60
61
61
- name : Get all upstream branches
62
62
id : get-upstream-branches
63
- if : github.event_name != 'pull_request '
63
+ if : github.event_name != 'pull_request_target '
64
64
run : |
65
65
# Get main branch and all version branches (*.*)
66
- branches=$(git branch -r | grep -E 'origin/(main|[0-9]+\.[0-9]+)' | sed 's/origin\///' | tr '\n' ' ')
66
+ branches=$(git branch -r | grep -E 'origin/(main|[0-9]+\.[0-9]+)$ ' | sed 's/origin\///' | tr '\n' ' ')
67
67
echo "Found upstream branches: $branches"
68
68
echo "upstream-branches=$branches" >> $GITHUB_OUTPUT
69
69
echo "output-branch-name=scheduled" >> $GITHUB_OUTPUT
70
70
71
71
- name : Get completed workflows from previous day
72
72
id : get-completed-workflows
73
- if : github.event_name != 'pull_request '
73
+ if : github.event_name != 'pull_request_target '
74
74
env :
75
75
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
76
76
run : |
94
94
95
95
- name : Check for successful scan artifacts from previous day
96
96
id : check-scan-artifacts
97
- if : github.event_name != 'pull_request '
97
+ if : github.event_name != 'pull_request_target '
98
98
env :
99
99
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
100
100
run : |
@@ -144,7 +144,7 @@ jobs:
144
144
145
145
- name : Determine security scan branches for scheduled runs
146
146
id : determine-scheduled-security-scan-branches
147
- if : github.event_name != 'pull_request '
147
+ if : github.event_name != 'pull_request_target '
148
148
run : |
149
149
upstream_branches="${{ steps.get-upstream-branches.outputs.upstream-branches }}"
150
150
successful_branches="${{ steps.check-scan-artifacts.outputs.successful-security-scan-branches }}"
@@ -181,7 +181,7 @@ jobs:
181
181
182
182
- name : Determine global dependencies branches for scheduled runs
183
183
id : determine-scheduled-global-dependencies-branches
184
- if : github.event_name != 'pull_request '
184
+ if : github.event_name != 'pull_request_target '
185
185
run : |
186
186
upstream_branches="${{ steps.get-upstream-branches.outputs.upstream-branches }}"
187
187
successful_branches="${{ steps.check-scan-artifacts.outputs.successful-global-dependencies-branches }}"
@@ -257,6 +257,7 @@ jobs:
257
257
# security scan scripts. So we download the latest one from main
258
258
echo "Downloading latest security-scan.sh script from main branch"
259
259
curl -sSL "https://raw.githubusercontent.com/${{ github.repository }}/main/scripts/security-scan.sh" -o scripts/security-scan.sh
260
+ sudo chmod +x scripts/security-scan.sh
260
261
echo "Updated security-scan.sh to latest version from main"
261
262
262
263
- name : Set up environment
@@ -323,7 +324,7 @@ jobs:
323
324
- name : Create Success Indicator File
324
325
run : |
325
326
# For PR events, use base_ref as output branch name, otherwise use actual branch
326
- if [ "${{ github.event_name }}" = "pull_request " ]; then
327
+ if [ "${{ github.event_name }}" = "pull_request_target " ]; then
327
328
output_branch="${{ needs.get-branches-to-scan.outputs.output-branch-name }}"
328
329
else
329
330
output_branch="${{ matrix.branch }}"
@@ -333,8 +334,8 @@ jobs:
333
334
- name : Upload Success Indicator File
334
335
uses : actions/upload-artifact@v4
335
336
with :
336
- name : scan-success-${{ matrix.target }}-${{ github.event_name == 'pull_request ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}
337
- path : scan-success-${{ matrix.target }}-${{ github.event_name == 'pull_request ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}.txt
337
+ name : scan-success-${{ matrix.target }}-${{ github.event_name == 'pull_request_target ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}
338
+ path : scan-success-${{ matrix.target }}-${{ github.event_name == 'pull_request_target ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}.txt
338
339
retention-days : 90
339
340
340
341
- name : Publish Scan Successful Metric
@@ -379,7 +380,7 @@ jobs:
379
380
targets=($(echo "$targets_json" | jq -r '.[]'))
380
381
381
382
# For PR events, use base_ref as output branch name, otherwise use actual branch
382
- if [ "${{ github.event_name }}" = "pull_request " ]; then
383
+ if [ "${{ github.event_name }}" = "pull_request_target " ]; then
383
384
check_branch="${{ needs.get-branches-to-scan.outputs.output-branch-name }}"
384
385
else
385
386
check_branch="${{ matrix.branch }}"
@@ -417,8 +418,8 @@ jobs:
417
418
if : success()
418
419
uses : actions/upload-artifact@v4
419
420
with :
420
- name : scan-success-branch-${{ github.event_name == 'pull_request ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}
421
- path : scan-success-branch-${{ github.event_name == 'pull_request ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}.txt
421
+ name : scan-success-branch-${{ github.event_name == 'pull_request_target ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}
422
+ path : scan-success-branch-${{ github.event_name == 'pull_request_target ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}.txt
422
423
retention-days : 90
423
424
424
425
security-scan-global-dependencies :
@@ -461,6 +462,7 @@ jobs:
461
462
# security scan scripts. So we download the latest one from main
462
463
echo "Downloading latest security-scan.sh script from main branch"
463
464
curl -sSL "https://raw.githubusercontent.com/${{ github.repository }}/main/scripts/security-scan.sh" -o scripts/security-scan.sh
465
+ sudo chmod +x scripts/security-scan.sh
464
466
echo "Updated security-scan.sh to latest version from main"
465
467
466
468
- name : Install Security Scan Dependencies
@@ -513,7 +515,7 @@ jobs:
513
515
- name : Create Global Success Indicator File
514
516
run : |
515
517
# For PR events, use base_ref as output branch name, otherwise use actual branch
516
- if [ "${{ github.event_name }}" = "pull_request " ]; then
518
+ if [ "${{ github.event_name }}" = "pull_request_target " ]; then
517
519
output_branch="${{ needs.get-branches-to-scan.outputs.output-branch-name }}"
518
520
else
519
521
output_branch="${{ matrix.branch }}"
@@ -523,8 +525,8 @@ jobs:
523
525
- name : Upload Global Success Indicator File
524
526
uses : actions/upload-artifact@v4
525
527
with :
526
- name : global-scan-success-${{ github.event_name == 'pull_request ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}
527
- path : global-scan-success-${{ github.event_name == 'pull_request ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}.txt
528
+ name : global-scan-success-${{ github.event_name == 'pull_request_target ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}
529
+ path : global-scan-success-${{ github.event_name == 'pull_request_target ' && needs.get-branches-to-scan.outputs.output-branch-name || matrix.branch }}.txt
528
530
retention-days : 90
529
531
530
532
- name : Publish Failure Metrics
0 commit comments