Skip to content

Commit d8e59aa

Browse files
ci: made CI pipelines use nix instead
This makes sure that all workflows use the same version of node as the runtime node it should use.
1 parent 50bd747 commit d8e59aa

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

.github/workflows/many--build-and-push-image.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ on:
2020
- '*[Dd]ocker*'
2121

2222
env:
23-
IMAGE: image
24-
TARGET: production
23+
IMAGE: slyde:latest
2524

2625
jobs:
2726
build:
@@ -34,6 +33,8 @@ jobs:
3433
steps:
3534
- name: Checkout repository
3635
uses: actions/[email protected]
36+
- name: Install Nix using cachix
37+
uses: cachix/[email protected]
3738
- name: Get image tags
3839
id: vars
3940
shell: bash
@@ -61,11 +62,7 @@ jobs:
6162
echo "tags=unstable" >> $GITHUB_OUTPUT
6263
fi
6364
- name: Build docker image
64-
run: docker build --target "$TARGET" --tag "$IMAGE" .
65-
- name: Basic container runtime test
66-
run: docker run --rm "$IMAGE" -- --help
67-
- name: Save image to disk
68-
run: docker save "$IMAGE" | gzip > image.tar.gz
65+
run: nix build --print-build-logs .#container
6966
- name: Creating unique artifact name
7067
id: artifact-name
7168
run: echo "name=${{ github.sha }}-${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
@@ -76,7 +73,7 @@ jobs:
7673
if-no-files-found: 'error'
7774
retention-days: 1
7875
include-hidden-files: true
79-
path: image.tar.gz
76+
path: result
8077

8178
deploy:
8279
name: Deploy to ${{ matrix.name }}
@@ -105,7 +102,11 @@ jobs:
105102
uses: actions/[email protected]
106103
with: { name: "${{ needs.build.outputs.artifact_name }}" }
107104
- name: Load image from disk
108-
run: docker load < image.tar.gz
105+
run: docker load < result
106+
- name: Basic container runtime test
107+
run: >
108+
PACKAGE_VERSION=$(jq -r '.version' package.json)
109+
docker run --rm "$IMAGE" --version | grep "$PACKAGE_VERSION"
109110
- name: Log in to Container Repository (${{ matrix.server }})
110111
run: docker login "$SERVER" --username "$USER" --password "$PASSWORD"
111112
env: { PASSWORD: "${{ secrets[matrix.password] }}" }

.github/workflows/many--publish-npm-package.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ jobs:
3434
steps:
3535
- name: Checkout repository
3636
uses: actions/[email protected]
37-
- name: Set up Node.js
38-
uses: actions/[email protected]
39-
with:
40-
node-version: 24
41-
cache-dependency-path: package-lock.json
42-
cache: 'npm'
37+
- name: Install Nix using cachix
38+
uses: cachix/[email protected]
39+
- name: Set up Node.js using nix
40+
run: nix profile install .#nodejs
4341
- name: Read `package.json` file and output contents
4442
id: package
4543
run: |
@@ -139,11 +137,10 @@ jobs:
139137
PACKAGE_NAME: ${{ needs.build.outputs.package_name }}
140138
PACKAGE_VERSION: ${{ needs.build.outputs.package_version }}
141139
steps:
142-
- name: Set up Node.js
143-
uses: actions/[email protected]
144-
with:
145-
node-version: 24
146-
registry-url: ${{ matrix.registry_url }}
140+
- name: Install Nix using cachix
141+
uses: cachix/[email protected]
142+
- name: Set up Node.js using nix
143+
run: nix profile install .#nodejs
147144
- name: Download build artifact
148145
uses: actions/[email protected]
149146
with: { name: "${{ needs.build.outputs.artifact_name }}" }

.github/workflows/push--basic-ci-checks.yaml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,10 @@ jobs:
2020
steps:
2121
- name: Checkout repository
2222
uses: actions/[email protected]
23-
- name: Set up Node.js
24-
uses: actions/[email protected]
25-
with:
26-
node-version: 24
27-
cache-dependency-path: package-lock.json
28-
cache: 'npm'
29-
- name: Restore npm cache
30-
uses: actions/[email protected]
31-
with:
32-
path: ~/.npm
33-
key: ${{ runner.os }}-node-24-${{ hashFiles('package-lock.json') }}
34-
restore-keys: |
35-
${{ runner.os }}-node-24-
23+
- name: Install Nix using cachix
24+
uses: cachix/[email protected]
25+
- name: Set up Node.js using nix
26+
run: nix profile install .#nodejs
3627
- name: Install all dependencies
3728
run: npm ci
3829
- name: Run task (npm run ${{ matrix.task }})

0 commit comments

Comments
 (0)