-
Notifications
You must be signed in to change notification settings - Fork 19
540 lines (481 loc) · 22.8 KB
/
Copy pathci.yml
File metadata and controls
540 lines (481 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
name: Validate CLIProxyAPI Pro
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
permissions:
actions: read
contents: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
concurrency:
group: validation-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' }}
jobs:
resolve-upstream:
runs-on: ubuntu-latest
outputs:
core_repo: ${{ steps.resolve.outputs.core_repo }}
core_tag: ${{ steps.resolve.outputs.core_tag }}
core_sha: ${{ steps.resolve.outputs.core_sha }}
core_source_date_epoch: ${{ steps.resolve.outputs.core_source_date_epoch }}
management_repo: ${{ steps.resolve.outputs.management_repo }}
management_tag: ${{ steps.resolve.outputs.management_tag }}
management_sha: ${{ steps.resolve.outputs.management_sha }}
pro_management_release_tag: ${{ steps.resolve.outputs.pro_management_release_tag }}
pro_management_asset_digest: ${{ steps.resolve.outputs.pro_management_asset_digest }}
steps:
- name: Checkout customizations
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Resolve upstream versions and source-image inputs
id: resolve
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CORE_UPSTREAM_REPO: router-for-me/CLIProxyAPI
MANAGEMENT_UPSTREAM_REPO: router-for-me/Cli-Proxy-API-Management-Center
CURRENT_REPO: ${{ github.repository }}
run: |
set -euo pipefail
core_tag="$(gh api "repos/${CORE_UPSTREAM_REPO}/releases/latest" --jq '.tag_name')"
management_tag="$(gh api "repos/${MANAGEMENT_UPSTREAM_REPO}/releases/latest" --jq '.tag_name')"
core_sha="$(gh api "repos/${CORE_UPSTREAM_REPO}/commits/${core_tag}" --jq '.sha')"
core_commit_date="$(gh api "repos/${CORE_UPSTREAM_REPO}/commits/${core_sha}" --jq '.commit.committer.date')"
core_source_date_epoch="$(date -u -d "${core_commit_date}" +%s)"
management_sha="$(gh api "repos/${MANAGEMENT_UPSTREAM_REPO}/commits/${management_tag}" --jq '.sha')"
pro_release="$(gh api "repos/${CURRENT_REPO}/releases/latest")"
pro_management_release_tag="$(jq -r '.tag_name' <<<"${pro_release}")"
pro_management_asset_digest="$(
jq -r '[.assets[] | select(.name == "management.html") | .digest // ""][0] // ""' \
<<<"${pro_release}"
)"
test -n "${pro_management_release_tag}"
test "${pro_management_release_tag}" != "null"
echo "core_repo=${CORE_UPSTREAM_REPO}" >> "${GITHUB_OUTPUT}"
echo "core_tag=${core_tag}" >> "${GITHUB_OUTPUT}"
echo "core_sha=${core_sha}" >> "${GITHUB_OUTPUT}"
echo "core_source_date_epoch=${core_source_date_epoch}" >> "${GITHUB_OUTPUT}"
echo "management_repo=${MANAGEMENT_UPSTREAM_REPO}" >> "${GITHUB_OUTPUT}"
echo "management_tag=${management_tag}" >> "${GITHUB_OUTPUT}"
echo "management_sha=${management_sha}" >> "${GITHUB_OUTPUT}"
echo "pro_management_release_tag=${pro_management_release_tag}" >> "${GITHUB_OUTPUT}"
echo "pro_management_asset_digest=${pro_management_asset_digest}" >> "${GITHUB_OUTPUT}"
classify-changes:
needs: resolve-upstream
runs-on: ubuntu-latest
outputs:
core: ${{ steps.classify.outputs.core }}
management: ${{ steps.classify.outputs.management }}
source_image: ${{ steps.classify.outputs.source_image }}
reason: ${{ steps.classify.outputs.reason }}
steps:
- name: Checkout customizations with history
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Locate previous successful validation state
id: previous
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT_NAME: ${{ github.event_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REF_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
echo "run_id=" >> "${GITHUB_OUTPUT}"
mkdir -p previous-validation
if [ "${EVENT_NAME}" = "workflow_dispatch" ]; then
exit 0
fi
runs_file="${RUNNER_TEMP}/successful-validation-runs.json"
if ! gh api \
"repos/${GITHUB_REPOSITORY}/actions/workflows/ci.yml/runs?status=success&per_page=50" \
> "${runs_file}"; then
echo "NOTICE: could not query prior validation runs; running full validation"
exit 0
fi
candidate_ids_file="${RUNNER_TEMP}/candidate-validation-runs.txt"
: > "${candidate_ids_file}"
if [ "${EVENT_NAME}" = "pull_request" ]; then
# shellcheck disable=SC2016
jq -r --argjson pr "${PR_NUMBER}" '
.workflow_runs[]
| select(.event == "pull_request")
| select(any(.pull_requests[]?; .number == $pr))
| .id
' "${runs_file}" >> "${candidate_ids_file}"
jq -r '
.workflow_runs[]
| select(.event == "push" and .head_branch == "main")
| .id
' "${runs_file}" >> "${candidate_ids_file}"
else
# shellcheck disable=SC2016
jq -r --arg branch "${REF_NAME}" '
.workflow_runs[]
| select(.event == "push" and .head_branch == $branch)
| .id
' "${runs_file}" >> "${candidate_ids_file}"
fi
while IFS= read -r run_id; do
[ -n "${run_id}" ] || continue
artifact_id="$(
gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}/artifacts" \
--jq '.artifacts[] | select(.name == "validation-state" and (.expired | not)) | .id' \
2>/dev/null | head -n 1 || true
)"
if [ -n "${artifact_id}" ]; then
if gh run download "${run_id}" \
--repo "${GITHUB_REPOSITORY}" \
--name validation-state \
--dir previous-validation >/dev/null 2>&1 && \
[ -f previous-validation/validation-state.json ]; then
echo "run_id=${run_id}" >> "${GITHUB_OUTPUT}"
exit 0
fi
rm -f previous-validation/validation-state.json
fi
done < "${candidate_ids_file}"
- name: Classify cumulative changes
id: classify
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.sha }}
CORE_SHA: ${{ needs.resolve-upstream.outputs.core_sha }}
MANAGEMENT_SHA: ${{ needs.resolve-upstream.outputs.management_sha }}
PRO_MANAGEMENT_RELEASE_TAG: ${{ needs.resolve-upstream.outputs.pro_management_release_tag }}
PRO_MANAGEMENT_ASSET_DIGEST: ${{ needs.resolve-upstream.outputs.pro_management_asset_digest }}
run: |
set -euo pipefail
state_file="previous-validation/validation-state.json"
paths_file="${RUNNER_TEMP}/validation-changed-paths.txt"
: > "${paths_file}"
force_all=false
core_upstream_changed=false
management_upstream_changed=false
image_input_changed=false
if [ ! -f "${state_file}" ]; then
force_all=true
elif ! jq -e '
(.head_sha | type == "string")
and (.core_sha | type == "string")
and (.management_sha | type == "string")
and (.pro_management_release_tag | type == "string")
and (.pro_management_asset_digest | type == "string")
' "${state_file}" >/dev/null; then
force_all=true
else
previous_core_sha="$(jq -r '.core_sha' "${state_file}")"
previous_management_sha="$(jq -r '.management_sha' "${state_file}")"
previous_pro_management_release_tag="$(jq -r '.pro_management_release_tag' "${state_file}")"
previous_pro_management_asset_digest="$(jq -r '.pro_management_asset_digest' "${state_file}")"
[ "${previous_core_sha}" = "${CORE_SHA}" ] || core_upstream_changed=true
[ "${previous_management_sha}" = "${MANAGEMENT_SHA}" ] || management_upstream_changed=true
if [ "${previous_pro_management_release_tag}" != "${PRO_MANAGEMENT_RELEASE_TAG}" ] || \
[ "${previous_pro_management_asset_digest}" != "${PRO_MANAGEMENT_ASSET_DIGEST}" ]; then
image_input_changed=true
fi
fi
if [ "${EVENT_NAME}" = "pull_request" ]; then
if ! git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null; then
force_all=true
else
git diff --name-only --diff-filter=ACDMRTUXB "${BASE_SHA}...${HEAD_SHA}" > "${paths_file}"
fi
elif [ "${EVENT_NAME}" = "push" ] && [ "${force_all}" = "false" ]; then
previous_head_sha="$(jq -r '.head_sha' "${state_file}")"
if git cat-file -e "${previous_head_sha}^{commit}" 2>/dev/null && \
git merge-base --is-ancestor "${previous_head_sha}" "${HEAD_SHA}"; then
git diff --name-only --diff-filter=ACDMRTUXB \
"${previous_head_sha}..${HEAD_SHA}" > "${paths_file}"
else
force_all=true
fi
else
force_all=true
fi
classifier_args=(
scripts/validation/classify_validation_changes.py
--paths-file "${paths_file}"
)
[ "${force_all}" = "false" ] || classifier_args+=(--force-all)
[ "${core_upstream_changed}" = "false" ] || classifier_args+=(--core-upstream-changed)
[ "${management_upstream_changed}" = "false" ] || classifier_args+=(--management-upstream-changed)
[ "${image_input_changed}" = "false" ] || classifier_args+=(--image-input-changed)
decision="$(python3 "${classifier_args[@]}")"
echo "core=$(jq -r '.core' <<<"${decision}")" >> "${GITHUB_OUTPUT}"
echo "management=$(jq -r '.management' <<<"${decision}")" >> "${GITHUB_OUTPUT}"
echo "source_image=$(jq -r '.source_image' <<<"${decision}")" >> "${GITHUB_OUTPUT}"
echo "reason=$(jq -r '.reason' <<<"${decision}")" >> "${GITHUB_OUTPUT}"
{
echo "## Validation routing"
echo
echo "- Reason: $(jq -r '.reason' <<<"${decision}")"
echo "- Core: $(jq -r '.core' <<<"${decision}")"
echo "- Management: $(jq -r '.management' <<<"${decision}")"
echo "- Source image: $(jq -r '.source_image' <<<"${decision}")"
echo
echo "Changed paths:"
# shellcheck disable=SC2016
sed 's/^/- `/; s/$/`/' "${paths_file}"
} >> "${GITHUB_STEP_SUMMARY}"
repo-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout customizations
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.x'
- name: Set up Go for actionlint
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
cache: false
- name: Install actionlint
env:
GOBIN: ${{ runner.temp }}/validation-bin
run: |
go install github.com/rhysd/actionlint/cmd/actionlint@v1.7.7
echo "${GOBIN}" >> "${GITHUB_PATH}"
- name: Validate repository sources
env:
VALIDATION_REQUIRE_TOOLS: "1"
run: bash scripts/validation/repo.sh
core-baseline:
needs:
- resolve-upstream
- classify-changes
if: needs.classify-changes.outputs.core == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout customizations
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: customizations-repo
- name: Checkout Core upstream
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ needs.resolve-upstream.outputs.core_repo }}
ref: ${{ needs.resolve-upstream.outputs.core_sha }}
path: upstream-core
- name: Configure explicit Go cache paths
run: |
echo "GOMODCACHE=${RUNNER_TEMP}/go-mod-cache" >> "${GITHUB_ENV}"
echo "GOCACHE=${RUNNER_TEMP}/go-build-cache" >> "${GITHUB_ENV}"
echo "STATICCHECK_CACHE=${RUNNER_TEMP}/staticcheck-cache" >> "${GITHUB_ENV}"
- name: Set up Go without implicit cache
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: upstream-core/go.mod
cache: false
- name: Restore Go module cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-mod-cache
key: ${{ runner.os }}-${{ runner.arch }}-go-mod-${{ hashFiles('upstream-core/go.sum', 'customizations-repo/cliproxyapi-pro-core/patches/apply_upstream_patches.py') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-go-mod-
- name: Restore rotating Go build cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/go-build-cache
key: ${{ runner.os }}-${{ runner.arch }}-go-build-${{ hashFiles('upstream-core/go.mod') }}-${{ needs.resolve-upstream.outputs.core_sha }}-${{ hashFiles('customizations-repo/cliproxyapi-pro-core/patches/**', 'customizations-repo/cliproxyapi-pro-core/embeddedusage/**', 'customizations-repo/scripts/validation/core.sh', 'customizations-repo/scripts/validation/compare_go_test_results.py') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-go-build-${{ hashFiles('upstream-core/go.mod') }}-${{ needs.resolve-upstream.outputs.core_sha }}-
${{ runner.os }}-${{ runner.arch }}-go-build-${{ hashFiles('upstream-core/go.mod') }}-
- name: Restore Staticcheck analysis cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/staticcheck-cache
key: ${{ runner.os }}-${{ runner.arch }}-staticcheck-v0.7.0-${{ hashFiles('upstream-core/go.mod') }}-${{ needs.resolve-upstream.outputs.core_sha }}-${{ hashFiles('customizations-repo/cliproxyapi-pro-core/patches/**', 'customizations-repo/scripts/validation/core.sh') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-staticcheck-v0.7.0-${{ hashFiles('upstream-core/go.mod') }}-${{ needs.resolve-upstream.outputs.core_sha }}-
${{ runner.os }}-${{ runner.arch }}-staticcheck-v0.7.0-${{ hashFiles('upstream-core/go.mod') }}-
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.x'
- name: Install Staticcheck
env:
GOBIN: ${{ runner.temp }}/validation-bin
run: |
go install honnef.co/go/tools/cmd/staticcheck@v0.7.0
echo "${GOBIN}" >> "${GITHUB_PATH}"
- name: Validate Core customization
env:
VALIDATION_ARTIFACT_DIR: ${{ runner.temp }}/core-validation-artifacts
VALIDATION_RACE: "1"
VALIDATION_STATICCHECK: "1"
run: bash customizations-repo/scripts/validation/core.sh upstream-core
- name: Upload Core validation diagnostics
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: core-validation-diagnostics
path: ${{ runner.temp }}/core-validation-artifacts
if-no-files-found: ignore
retention-days: 7
source-image-build:
needs:
- resolve-upstream
- classify-changes
if: needs.classify-changes.outputs.source_image == 'true' && github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout customizations
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
- name: Compute deterministic source date
id: source-date
env:
CORE_SOURCE_DATE_EPOCH: ${{ needs.resolve-upstream.outputs.core_source_date_epoch }}
run: |
customization_source_date_epoch="$(git show -s --format=%ct HEAD)"
source_date_epoch="$(printf '%s\n' "${CORE_SOURCE_DATE_EPOCH}" "${customization_source_date_epoch}" | sort -n | tail -n 1)"
echo "value=${source_date_epoch}" >> "${GITHUB_OUTPUT}"
- name: Build source Dockerfile with shared layer cache
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
file: cliproxyapi-pro-core/Dockerfile
load: false
push: false
tags: cli-proxy-api-pro:review
build-args: |
CLIPROXY_VERSION=${{ needs.resolve-upstream.outputs.core_tag }}
CLIPROXY_COMMIT=${{ needs.resolve-upstream.outputs.core_sha }}
CLIPROXY_BUILD_VERSION=${{ needs.resolve-upstream.outputs.core_tag }}-pro-review
PRO_MANAGEMENT_VERSION=${{ needs.resolve-upstream.outputs.pro_management_release_tag }}
PRO_MANAGEMENT_DIGEST=${{ needs.resolve-upstream.outputs.pro_management_asset_digest }}
SOURCE_DATE_EPOCH=${{ steps.source-date.outputs.value }}
cache-from: type=gha,scope=validate-source-image
cache-to: type=gha,scope=validate-source-image,mode=max,timeout=60s,ignore-error=true
management-baseline:
needs:
- resolve-upstream
- classify-changes
if: needs.classify-changes.outputs.management == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout customizations
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: customizations-repo
- name: Checkout Management upstream
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ needs.resolve-upstream.outputs.management_repo }}
ref: ${{ needs.resolve-upstream.outputs.management_sha }}
path: upstream-management
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: upstream-management/package.json
- name: Cache Bun dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('upstream-management/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Validate Management customization
env:
VERSION: ${{ needs.resolve-upstream.outputs.management_tag }}-pro-review
run: bash customizations-repo/scripts/validation/management.sh upstream-management
validation-summary:
needs:
- resolve-upstream
- classify-changes
- repo-tests
- core-baseline
- management-baseline
- source-image-build
if: always()
runs-on: ubuntu-latest
steps:
- name: Enforce required validation results
env:
EVENT_NAME: ${{ github.event_name }}
RESOLVE_RESULT: ${{ needs.resolve-upstream.result }}
CLASSIFY_RESULT: ${{ needs.classify-changes.result }}
REPO_RESULT: ${{ needs.repo-tests.result }}
CORE_REQUIRED: ${{ needs.classify-changes.outputs.core }}
CORE_RESULT: ${{ needs.core-baseline.result }}
MANAGEMENT_REQUIRED: ${{ needs.classify-changes.outputs.management }}
MANAGEMENT_RESULT: ${{ needs.management-baseline.result }}
IMAGE_REQUIRED: ${{ needs.classify-changes.outputs.source_image }}
IMAGE_RESULT: ${{ needs.source-image-build.result }}
run: |
set -euo pipefail
require_result() {
local name="$1"
local required="$2"
local result="$3"
if [ "${required}" = "true" ]; then
if [ "${result}" != "success" ]; then
echo "${name} was required but finished with ${result}" >&2
return 1
fi
elif [ "${result}" != "skipped" ]; then
echo "${name} was not required but finished with ${result}" >&2
return 1
fi
}
test "${RESOLVE_RESULT}" = "success"
test "${CLASSIFY_RESULT}" = "success"
test "${REPO_RESULT}" = "success"
require_result "Core validation" "${CORE_REQUIRED}" "${CORE_RESULT}"
require_result "Management validation" "${MANAGEMENT_REQUIRED}" "${MANAGEMENT_RESULT}"
if [ "${EVENT_NAME}" = "workflow_dispatch" ]; then
test "${IMAGE_RESULT}" = "skipped"
else
require_result "Source image validation" "${IMAGE_REQUIRED}" "${IMAGE_RESULT}"
fi
record-validation-state:
needs:
- resolve-upstream
- classify-changes
- validation-summary
if: needs.validation-summary.result == 'success' && github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Write validated input state
env:
HEAD_SHA: ${{ github.sha }}
CORE_SHA: ${{ needs.resolve-upstream.outputs.core_sha }}
MANAGEMENT_SHA: ${{ needs.resolve-upstream.outputs.management_sha }}
PRO_MANAGEMENT_RELEASE_TAG: ${{ needs.resolve-upstream.outputs.pro_management_release_tag }}
PRO_MANAGEMENT_ASSET_DIGEST: ${{ needs.resolve-upstream.outputs.pro_management_asset_digest }}
run: |
mkdir -p validation-state
python3 - <<'PY'
import json
import os
from pathlib import Path
state = {
"head_sha": os.environ["HEAD_SHA"],
"core_sha": os.environ["CORE_SHA"],
"management_sha": os.environ["MANAGEMENT_SHA"],
"pro_management_release_tag": os.environ["PRO_MANAGEMENT_RELEASE_TAG"],
"pro_management_asset_digest": os.environ["PRO_MANAGEMENT_ASSET_DIGEST"],
}
Path("validation-state/validation-state.json").write_text(
json.dumps(state, indent=2, sort_keys=True) + "\n",
encoding="utf-8",
)
PY
- name: Upload validation state
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: validation-state
path: validation-state/validation-state.json
if-no-files-found: error
retention-days: 30