55 pull_request :
66 branches :
77 - main
8- - " rc/**"
98 - next
109
1110 push :
1211 branches :
1312 - main
14- - " rc/**"
1513 - next
1614
15+ workflow_call :
16+ inputs :
17+ ref :
18+ description : |
19+ The ref to run the tests on.
20+ type : string
21+ required : true
22+
1723env :
1824 XARGS_MAX_PROCS : 4
1925
2026jobs :
27+ determine-ref :
28+ runs-on : ubuntu-latest
29+ outputs :
30+ ref : ${{ steps.set-ref.outputs.ref }}
31+ env :
32+ REF_FROM_INPUT : ${{ inputs.ref }}
33+ EVENT_NAME : ${{ github.event_name }}
34+ steps :
35+ - id : set-ref
36+ run : |
37+ if [[ "$EVENT_NAME" == "workflow_dispatch" ]] || [[ "$EVENT_NAME" == "workflow_call" ]]; then
38+ echo "ref=$REF_FROM_INPUT" >> "$GITHUB_OUTPUT"
39+ else
40+ echo "ref=$GITHUB_REF" >> "$GITHUB_OUTPUT"
41+ fi
42+
2143 prepare-code-scanning-pack-matrix :
2244 name : Prepare CodeQL Code Scanning pack matrix
45+ needs : [determine-ref]
2346 runs-on : ubuntu-22.04
2447 outputs :
2548 matrix : ${{ steps.export-code-scanning-pack-matrix.outputs.matrix }}
2649 steps :
2750 - name : Checkout repository
28- uses : actions/checkout@v2
51+ uses : actions/checkout@v4
52+ with :
53+ ref : ${{ needs.determine-ref.outputs.ref }}
2954
3055 - name : Export Code Scanning pack matrix
3156 id : export-code-scanning-pack-matrix
@@ -36,13 +61,15 @@ jobs:
3661
3762 create-code-scanning-pack :
3863 name : Create Code Scanning pack
39- needs : prepare-code-scanning-pack-matrix
64+ needs : [ prepare-code-scanning-pack-matrix, determine-ref]
4065 runs-on : ubuntu-20.04-xl
4166 strategy :
4267 fail-fast : false
4368 matrix : ${{ fromJSON(needs.prepare-code-scanning-pack-matrix.outputs.matrix) }}
4469 steps :
45- - uses : actions/checkout@v2
70+ - uses : actions/checkout@v4
71+ with :
72+ ref : ${{ needs.determine-ref.outputs.ref }}
4673
4774 - name : Cache CodeQL
4875 id : cache-codeql
@@ -68,15 +95,15 @@ jobs:
6895 - name : Checkout external help files
6996 continue-on-error : true
7097 id : checkout-external-help-files
71- uses : actions/checkout@v2
98+ uses : actions/checkout@v4
7299 with :
73100 ssh-key : ${{ secrets.CODEQL_CODING_STANDARDS_HELP_KEY }}
74101 repository : " github/codeql-coding-standards-help"
75- ref : ${{ github.head_ref }}
102+ ref : ${{ needs.determine-ref.outputs.ref }}
76103 path : external-help-files
77104
78105 - name : Include external help files
79- if : ${{ steps.checkout-external-help-files.outcome == 'success' }}
106+ if : steps.checkout-external-help-files.outcome == 'success'
80107 run : |
81108 pushd external-help-files
82109 find . -name '*.md' -exec rsync -av --relative {} "$GITHUB_WORKSPACE" \;
0 commit comments