Skip to content

Commit 3174393

Browse files
committed
Validate we can generate deploy artifacts
1 parent a715b63 commit 3174393

File tree

2 files changed

+89
-8
lines changed

2 files changed

+89
-8
lines changed

.github/workflows/code-scanning-pack-gen.yml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,52 @@ on:
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+
1723
env:
1824
XARGS_MAX_PROCS: 4
1925

2026
jobs:
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" \;

.github/workflows/validate-release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,60 @@ jobs:
222222
--input - \
223223
/repos/$GITHUB_REPOSITORY/check-runs/$CHECK_RUN_ID
224224
225+
pre-generate-packs:
226+
needs: [determine-ref]
227+
runs-on: ubuntu-latest
228+
if: github.event_name != 'pull_request'
229+
outputs:
230+
check-run-id: ${{ steps.create-check-run.outputs.check-run-id }}
231+
steps:
232+
- name: Create check run
233+
id: create-check-run
234+
env:
235+
REF: ${{ needs.determine-ref.outputs.ref }}
236+
GH_TOKEN: ${{ github.token }}
237+
run: |
238+
check_run_id=$(gh api \
239+
--header "Accept: application/vnd.github+json" \
240+
--header "X-GitHub-Api-Version: 2022-11-28" \
241+
--field name="Code Scanning Query Pack Generation" \
242+
--field head_sha="$REF" \
243+
--field status="in_progress" \
244+
--jq ".id" \
245+
/repos/$GITHUB_REPOSITORY/check-runs)
246+
247+
echo "check-run-id=$check_run_id" >> "$GITHUB_OUTPUT"
248+
249+
generate-packs:
250+
needs: [determine-ref, pre-generate-packs]
251+
if: needs.pre-generate-packs.result != 'failure'
252+
uses: ./.github/workflows/code-scanning-pack-gen.yml
253+
with:
254+
ref: ${{ needs.determine-ref.outputs.ref }}
255+
256+
post-generate-packs:
257+
needs: [pre-generate-packs, generate-packs]
258+
if: always() && github.event_name != 'pull_request'
259+
runs-on: ubuntu-latest
260+
steps:
261+
- name: Update check run
262+
env:
263+
CHECK_RUN_ID: ${{ needs.pre-generate-packs.outputs.check-run-id }}
264+
CHECK_RUN_CONCLUSION: ${{ needs.generate-packs.result }}
265+
GH_TOKEN: ${{ github.token }}
266+
run: |
267+
jq -n \
268+
--arg status "completed" \
269+
--arg conclusion "$CHECK_RUN_CONCLUSION" \
270+
'{status: $status, conclusion: $conclusion}' \
271+
| \
272+
gh api \
273+
--method PATCH \
274+
--header "Accept: application/vnd.github+json" \
275+
--header "X-GitHub-Api-Version: 2022-11-28" \
276+
--input - \
277+
/repos/$GITHUB_REPOSITORY/check-runs/$CHECK_RUN_ID
278+
225279
create-release-status-check-run:
226280
name: "Initialize release status monitoring"
227281
needs: [determine-ref]

0 commit comments

Comments
 (0)