@norskvideo/ctl-dev-kit 0.2.145 → 0.2.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -35,6 +35,16 @@
|
|
|
35
35
|
#
|
|
36
36
|
# Repo-local for now; to be hoisted into id3as/ci-workflows as a reusable
|
|
37
37
|
# workflow (RFC 0001 Workstream E).
|
|
38
|
+
#
|
|
39
|
+
# The jobs that log in to Docker Hub (build, publish) run docker with
|
|
40
|
+
# DOCKER_CONFIG set to a job-local directory under $RUNNER_TEMP that holds only
|
|
41
|
+
# this job's own login, deleted when the job ends. The runners are shared and
|
|
42
|
+
# their own ~/.docker is not ours: on the shared arm pool a stale Docker Hub
|
|
43
|
+
# login there made the build's pull of public bases (node:22-slim, oven/bun)
|
|
44
|
+
# fail with 401 "incorrect username or password" before this job had logged in.
|
|
45
|
+
# The bases are public, so those pulls are now anonymous. The runner images ship
|
|
46
|
+
# buildx as a system plugin and use the default docker socket, so the empty
|
|
47
|
+
# config loses nothing. norsk-cloud's build-images.yml does the same (f7c1898e).
|
|
38
48
|
name: build-image
|
|
39
49
|
|
|
40
50
|
on:
|
|
@@ -188,6 +198,14 @@ jobs:
|
|
|
188
198
|
arch: arm64
|
|
189
199
|
runs-on: ${{ matrix.runner }}
|
|
190
200
|
steps:
|
|
201
|
+
- name: Job-local docker config
|
|
202
|
+
# Before anything touches docker (see the header): this job's own login
|
|
203
|
+
# only, never the runner's ~/.docker.
|
|
204
|
+
run: |
|
|
205
|
+
rm -rf "$RUNNER_TEMP/docker-config"
|
|
206
|
+
mkdir -m 700 "$RUNNER_TEMP/docker-config"
|
|
207
|
+
echo "DOCKER_CONFIG=$RUNNER_TEMP/docker-config" >> "$GITHUB_ENV"
|
|
208
|
+
|
|
191
209
|
# Runs BEFORE checkout, and does two things: points the harness's temp base
|
|
192
210
|
# out of the workspace for every later step in this job, and clears whatever
|
|
193
211
|
# the old repo-local default left behind on this runner. The body carries the
|
|
@@ -282,6 +300,7 @@ jobs:
|
|
|
282
300
|
with:
|
|
283
301
|
username: norskvideo
|
|
284
302
|
password: ${{ secrets.DOCKER_PAT }}
|
|
303
|
+
logout: false # the last step deletes the whole config, the login with it
|
|
285
304
|
|
|
286
305
|
- name: Push the per-arch image to Docker Hub
|
|
287
306
|
if: ${{ env.PUBLISH_IMAGE != '' && github.event_name != 'pull_request' }}
|
|
@@ -304,6 +323,9 @@ jobs:
|
|
|
304
323
|
echo "::warning::removing containers this job left running:$s"
|
|
305
324
|
docker rm -f $s
|
|
306
325
|
fi
|
|
326
|
+
- name: Remove the job-local docker config
|
|
327
|
+
if: always()
|
|
328
|
+
run: rm -rf "$RUNNER_TEMP/docker-config"
|
|
307
329
|
|
|
308
330
|
# THE PUBLISH GATE. Nothing is published -- no dated tag, no channel tag, no
|
|
309
331
|
# channels row -- until both halves pass: the repo's own checks, and its guides
|
|
@@ -864,6 +886,14 @@ jobs:
|
|
|
864
886
|
if: ${{ needs.label.outputs.publish == 'true' && !inputs.dry_run && github.event_name != 'pull_request' }}
|
|
865
887
|
runs-on: x64
|
|
866
888
|
steps:
|
|
889
|
+
- name: Job-local docker config
|
|
890
|
+
# Before anything touches docker (see the header): this job's own login
|
|
891
|
+
# only, never the runner's ~/.docker.
|
|
892
|
+
run: |
|
|
893
|
+
rm -rf "$RUNNER_TEMP/docker-config"
|
|
894
|
+
mkdir -m 700 "$RUNNER_TEMP/docker-config"
|
|
895
|
+
echo "DOCKER_CONFIG=$RUNNER_TEMP/docker-config" >> "$GITHUB_ENV"
|
|
896
|
+
|
|
867
897
|
# Runs BEFORE checkout, and does two things: points the harness's temp base
|
|
868
898
|
# out of the workspace for every later step in this job, and clears whatever
|
|
869
899
|
# the old repo-local default left behind on this runner. The body carries the
|
|
@@ -932,6 +962,7 @@ jobs:
|
|
|
932
962
|
with:
|
|
933
963
|
username: norskvideo
|
|
934
964
|
password: ${{ secrets.DOCKER_PAT }}
|
|
965
|
+
logout: false # the last step deletes the whole config, the login with it
|
|
935
966
|
|
|
936
967
|
- name: Create + push the multi-arch manifest (dated label + channel)
|
|
937
968
|
run: |
|
|
@@ -964,6 +995,9 @@ jobs:
|
|
|
964
995
|
echo "::warning::removing containers this job left running:$s"
|
|
965
996
|
docker rm -f $s
|
|
966
997
|
fi
|
|
998
|
+
- name: Remove the job-local docker config
|
|
999
|
+
if: always()
|
|
1000
|
+
run: rm -rf "$RUNNER_TEMP/docker-config"
|
|
967
1001
|
|
|
968
1002
|
# Record the published image in this product's channels object
|
|
969
1003
|
# (s3://norsk.video/products/<product>/channels.json), which ctl reads to
|
|
@@ -366,3 +366,67 @@ export function jobsEnteringUnrootedShell(yaml: string): string[] {
|
|
|
366
366
|
});
|
|
367
367
|
return bad;
|
|
368
368
|
}
|
|
369
|
+
|
|
370
|
+
/** The first step of every job that logs in to a registry, and its always()
|
|
371
|
+
* partner at the end, named so the guard below can find them. */
|
|
372
|
+
export const DOCKER_CONFIG_STEP = "Job-local docker config";
|
|
373
|
+
export const DOCKER_CONFIG_REMOVE_STEP = "Remove the job-local docker config";
|
|
374
|
+
|
|
375
|
+
// The arm pool is shared, and its runners carry their own ~/.docker with a
|
|
376
|
+
// stale Docker Hub login. A build that read it failed its pull of public bases
|
|
377
|
+
// (node:22-slim, oven/bun) with "401 incorrect username or password" before the
|
|
378
|
+
// job's own login had run (norsk-relay, 2026-11-17, once its arm leg moved to
|
|
379
|
+
// the pool). So a job that logs in points DOCKER_CONFIG at a directory of its
|
|
380
|
+
// own under $RUNNER_TEMP before anything touches docker -- the pre-checkout
|
|
381
|
+
// step already pulls alpine -- logs in there only, and deletes it at the end.
|
|
382
|
+
// The login action's own logout is off: by its post step the directory is gone.
|
|
383
|
+
// norsk-cloud's build-images.yml did the same first (f7c1898e).
|
|
384
|
+
const DOCKER_CONFIG_REQUIREMENTS: { name: string; ok: (body: string) => boolean }[] = [
|
|
385
|
+
{ name: "export", ok: (b) => /DOCKER_CONFIG=\$RUNNER_TEMP\/[\w-]+"? >> "\$GITHUB_ENV"/.test(b) },
|
|
386
|
+
{ name: "fresh", ok: (b) => /rm -rf "\$RUNNER_TEMP\/[\w-]+"/.test(b) && /mkdir -m 700 /.test(b) },
|
|
387
|
+
];
|
|
388
|
+
|
|
389
|
+
/** Jobs that use `docker/login-action` without the job-local docker config:
|
|
390
|
+
* `<job>: <what is missing>`, where missing is `first` (no valid
|
|
391
|
+
* {@link DOCKER_CONFIG_STEP} as the job's first step), `logout` (a login that
|
|
392
|
+
* leaves the action's logout on) or `remove` (no always() removal step). */
|
|
393
|
+
export function jobDockerConfigProblems(yaml: string): string[] {
|
|
394
|
+
const lines = yaml.split("\n");
|
|
395
|
+
const out: string[] = [];
|
|
396
|
+
let job: string | undefined;
|
|
397
|
+
let start = 0;
|
|
398
|
+
const settle = (end: number) => {
|
|
399
|
+
if (job === undefined) return;
|
|
400
|
+
const body = lines.slice(start, end);
|
|
401
|
+
const logins = body.flatMap((l, i) => (/^\s*-?\s*uses: docker\/login-action@/.test(l) ? [i] : []));
|
|
402
|
+
if (logins.length === 0) return;
|
|
403
|
+
const missing: string[] = [];
|
|
404
|
+
const firstStep = body.findIndex((l) => /^ {6}- /.test(l));
|
|
405
|
+
const first = firstStep < 0 ? "" : (body[firstStep] as string);
|
|
406
|
+
const firstOk =
|
|
407
|
+
first.includes(`- name: ${DOCKER_CONFIG_STEP}`) &&
|
|
408
|
+
DOCKER_CONFIG_REQUIREMENTS.every((r) => r.ok(stepBody(lines, start + firstStep)));
|
|
409
|
+
if (!firstOk) missing.push("first");
|
|
410
|
+
const loggedOut = logins.some((i) => {
|
|
411
|
+
const next = body.findIndex((l, j) => j > i && /^ {6}- /.test(l));
|
|
412
|
+
return !body.slice(i, next < 0 ? body.length : next).some((l) => /^\s*logout: false\b/.test(l));
|
|
413
|
+
});
|
|
414
|
+
if (loggedOut) missing.push("logout");
|
|
415
|
+
const remove = body.findIndex((l) => l.includes(`- name: ${DOCKER_CONFIG_REMOVE_STEP}`));
|
|
416
|
+
const removeOk =
|
|
417
|
+
remove >= 0 &&
|
|
418
|
+
body.slice(remove + 1, remove + 4).some((l) => /^\s*if: always\(\)\s*$/.test(l)) &&
|
|
419
|
+
/rm -rf "\$RUNNER_TEMP\/[\w-]+"/.test(body.slice(remove, remove + 5).join("\n"));
|
|
420
|
+
if (!removeOk) missing.push("remove");
|
|
421
|
+
if (missing.length > 0) out.push(`${job}: ${missing.join(", ")}`);
|
|
422
|
+
};
|
|
423
|
+
lines.forEach((line, i) => {
|
|
424
|
+
const head = line.match(/^ {2}([A-Za-z_][\w-]*):\s*$/);
|
|
425
|
+
if (!head) return;
|
|
426
|
+
settle(i);
|
|
427
|
+
job = head[1];
|
|
428
|
+
start = i;
|
|
429
|
+
});
|
|
430
|
+
settle(lines.length);
|
|
431
|
+
return out;
|
|
432
|
+
}
|