Skip to content

Commit 8441752

Browse files
authored
Use shared Bash image CI from kool-dev/action (#92)
* Use shared Bash native-image CI from kool * Pin shared image tooling from kool-dev/action * Call the publisher action directly and trim repeated documentation
1 parent c1e4219 commit 8441752

3 files changed

Lines changed: 109 additions & 98 deletions

File tree

‎.github/workflows/ci-cd.yml‎

Lines changed: 90 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,115 @@
11
name: CI/CD
2-
32
on:
43
push:
5-
branches:
6-
- master
4+
branches: [master]
75
pull_request:
86
workflow_dispatch:
97
schedule:
108
- cron: '0 0 * * 0'
11-
9+
permissions:
10+
contents: read
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1214
jobs:
15+
checks:
16+
runs-on: ubuntu-24.04
17+
outputs:
18+
tags: ${{ steps.tags.outputs.tags }}
19+
steps:
20+
- uses: actions/checkout@v7
21+
- name: Check generated contexts and architecture selection
22+
run: |
23+
docker run --rm -v "$PWD:/app" fireworkweb/fwd:v1.0 fwd template
24+
git diff --exit-code
25+
bash tests/architecture.sh
26+
- id: tags
27+
run: echo "tags=$(jq -c '[.builds[].name] + [\"24-nginx\"]' fwd-template.json)" >> "$GITHUB_OUTPUT"
1328
build:
29+
needs: checks
30+
runs-on: ${{ matrix.platform.runner }}
1431
strategy:
32+
fail-fast: false
1533
matrix:
16-
version: [22, 24, 26]
17-
runs-on: [ubuntu-24.04, ubuntu-24.04-arm]
18-
runs-on: ${{ matrix.runs-on }}
19-
34+
version: ["22", "24", "26"]
35+
platform:
36+
- {arch: amd64, runner: ubuntu-24.04}
37+
- {arch: arm64, runner: ubuntu-24.04-arm}
2038
steps:
21-
- name: Checkout code
22-
uses: actions/checkout@v6
23-
24-
- name: Set up Docker Buildx
25-
uses: docker/setup-buildx-action@v3
26-
27-
- name: Check generated contexts and architecture selection
28-
run: |
29-
python3 tests/generated.py
30-
sh tests/architecture.sh
31-
32-
- name: Compute cache week
33-
id: cachekey
34-
run: echo "week=$(date -u +%Y-%V)" >> "$GITHUB_OUTPUT"
35-
36-
- name: Cache Docker layers
37-
uses: actions/cache@v5
39+
- uses: actions/checkout@v7
40+
- uses: kool-dev/action/image-build@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
41+
with:
42+
arch: ${{ matrix.platform.arch }}
43+
- name: Build fresh base
44+
id: base
45+
uses: docker/build-push-action@v7
3846
with:
39-
path: /tmp/.buildx-cache
40-
key: docker-buildx-${{ matrix.runs-on }}-${{ matrix.version }}-${{ steps.cachekey.outputs.week }}-${{ github.sha }}
41-
restore-keys: docker-buildx-${{ matrix.runs-on }}-${{ matrix.version }}-${{ steps.cachekey.outputs.week }}-
42-
43-
- name: Build
47+
context: ${{ matrix.version }}
48+
platforms: linux/${{ matrix.platform.arch }}
49+
pull: true
50+
load: true
51+
provenance: false
52+
tags: kooldev/node:${{ matrix.version }}
53+
- name: Test base
54+
env:
55+
IMAGE: ${{ steps.base.outputs.imageid }}
56+
run: bash tests/image.sh "$IMAGE"
57+
- name: Build nginx from this job's Node 24
58+
if: matrix.version == '24'
59+
id: nginx
60+
uses: docker/build-push-action@v7
61+
with:
62+
context: 24-nginx
63+
build-args: NODE_IMAGE=kooldev/node:24
64+
platforms: linux/${{ matrix.platform.arch }}
65+
load: true
66+
provenance: false
67+
tags: kooldev/node:24-nginx
68+
- uses: kool-dev/action/image-parent@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
69+
if: matrix.version == '24'
70+
with:
71+
base-ref: kooldev/node:24
72+
base-id: ${{ steps.base.outputs.imageid }}
73+
image-id: ${{ steps.nginx.outputs.imageid }}
74+
- name: Test nginx
75+
if: matrix.version == '24'
76+
env:
77+
IMAGE: ${{ steps.nginx.outputs.imageid }}
4478
run: |
45-
docker buildx build \
46-
--pull \
47-
--cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }} \
48-
--cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }} \
49-
--output type=docker \
50-
--tag "kooldev/node:${{ matrix.version }}-$(arch)" \
51-
${{ matrix.version }}
52-
53-
- name: Tests
54-
run: sh tests/image.sh "kooldev/node:${{ matrix.version }}-$(arch)"
55-
56-
# Use the Docker engine's loaded, freshly tested parent, not yesterday's Hub tag.
57-
- name: Build and test nginx from this run's Node 24
58-
if: matrix.version == 24
79+
bash tests/image.sh "$IMAGE"
80+
docker run --rm "$IMAGE" nginx -t
81+
- name: Collect tested IDs
82+
id: images
83+
env:
84+
VERSION: ${{ matrix.version }}
85+
BASE_ID: ${{ steps.base.outputs.imageid }}
86+
NGINX_ID: ${{ steps.nginx.outputs.imageid }}
5987
run: |
60-
docker build --builder default --pull=false \
61-
--build-arg "NODE_IMAGE=kooldev/node:24-$(arch)" \
62-
--tag "kooldev/node:24-nginx-$(arch)" 24-nginx
63-
sh tests/image.sh "kooldev/node:24-nginx-$(arch)"
64-
docker run --rm "kooldev/node:24-nginx-$(arch)" nginx -t
65-
66-
- name: Login to DockerHub
67-
uses: docker/login-action@v3
88+
images=$(jq -cn --arg version "$VERSION" --arg bid "$BASE_ID" --arg nid "$NGINX_ID" \
89+
'[{tag:$version,id:$bid}] + if $nid == "" then [] else [{tag:"24-nginx",id:$nid}] end')
90+
echo "images=$images" >> "$GITHUB_OUTPUT"
91+
- uses: kool-dev/action/image-stage@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
6892
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
6993
with:
94+
canonical-repository: kool-dev/docker-node
95+
default-branch: master
96+
repository: kooldev/node
97+
arch: ${{ matrix.platform.arch }}
98+
group: ${{ matrix.version }}
99+
images: ${{ steps.images.outputs.images }}
70100
username: ${{ secrets.DOCKER_USERNAME }}
71101
password: ${{ secrets.DOCKER_PASSWORD }}
72-
73-
- name: Push to DockerHub
74-
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
75-
run: |
76-
docker push "kooldev/node:${{ matrix.version }}-$(arch)"
77-
if [ "${{ matrix.version }}" = "24" ]; then
78-
docker push "kooldev/node:24-nginx-$(arch)"
79-
fi
80-
81-
amend:
102+
publish:
103+
needs: [checks, build]
82104
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
83-
needs: build
84105
runs-on: ubuntu-24.04
85-
strategy:
86-
matrix:
87-
version: [22, 24, 24-nginx, 26]
88-
89106
steps:
90-
- uses: docker/login-action@v3
107+
- uses: kool-dev/action/image-publish@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
91108
with:
109+
canonical-repository: kool-dev/docker-node
110+
default-branch: master
111+
repository: kooldev/node
112+
tags: ${{ needs.checks.outputs.tags }}
113+
architecture-aliases: true
92114
username: ${{ secrets.DOCKER_USERNAME }}
93115
password: ${{ secrets.DOCKER_PASSWORD }}
94-
95-
- run: |
96-
docker manifest create kooldev/node:${{ matrix.version }} \
97-
--amend kooldev/node:${{ matrix.version }}-x86_64 \
98-
--amend kooldev/node:${{ matrix.version }}-aarch64
99-
100-
docker manifest push kooldev/node:${{ matrix.version }}

‎README.md‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,28 @@ pnpm-only or removed `scripts-prepend-node-path` options in `.npmrc`.
7575
With current pnpm, hoisting policy belongs in the project's
7676
`pnpm-workspace.yaml`; set `shamefullyHoist: true` there if required.
7777

78-
Run `python3 tests/generated.py` and `sh tests/architecture.sh` to check
79-
generated contexts and download selection. After building an image, run
78+
Run `docker run --rm -v "$PWD:/app" fireworkweb/fwd:v1.0 fwd template`,
79+
`git diff --exit-code`, and `bash tests/architecture.sh` to check
80+
generated contexts and download selection with the real template engine. After building an image, run
8081
`sh tests/image.sh IMAGE` to exercise dockerize, npm, yarn, pnpm, config
8182
resolution and ownership as root and two remapped user IDs.
8283

84+
### Shared native publication
85+
86+
CI uses [shared Bash/`jq` actions](https://github.com/kool-dev/action/blob/master/image-ci.md),
87+
pinned in the workflow. Native amd64/arm64 jobs build/test once. Node 24
88+
NGINX inherits this job's tested Node parent, verified by ID and layer ancestry.
89+
The old per-run local Buildx cache export is replaced by the common Docker
90+
driver so derived images resolve fresh local parents consistently.
91+
92+
Only trusted `master` releases stage tested IDs under run/attempt-scoped tags.
93+
One publisher validates all four stable tags × both architectures before stable
94+
updates. Historical `-x86_64`/`-aarch64` tags remain compatibility aliases, but
95+
are updated only after the full native matrix succeeds. PRs/forks/feature branches
96+
cannot log in or publish. Release runs serialize; only PR runs are canceled.
97+
On failure, rerun **all jobs**: no previous-attempt metadata is reused and there
98+
is no resume workflow. Stable updates are not atomic across tags.
99+
83100
### Updating images and building locally
84101

85102
> You must have [`kool`](https://github.com/kool-dev/kool) installed.

‎tests/generated.py‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)