workflow: test post-build hook

This commit is contained in:
cy 2025-04-20 01:27:05 -04:00
parent 140f0f5dcf
commit c193ba2108
Signed by: cy
SSH key fingerprint: SHA256:o/geVWV4om1QhUSkKvDQeW/eAihwnjyXkqMwrVdbuts
2 changed files with 20 additions and 5 deletions

View file

@ -39,6 +39,17 @@ jobs:
- name: setup binary cache key
run: echo -n "${{ secrets.NIX_CACHE_SECRET_KEY }}" | xxd -p -r > ${{ runner.temp }}/cache-priv-key.pem
- name: Sync repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: post-build-hook
run: |
sudo mkdir -p /etc/nix
sudo cp ci/upload-to-cache.sh /etc/nix/
sudo chmod +x /etc/nix/upload-to-cache.sh
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
@ -51,11 +62,7 @@ jobs:
secret-key-files = ${{ runner.temp }}/cache-priv-key.pem
extra-substituters = https://nixcache.cy7.sh
extra-trusted-public-keys = nixcache.cy7.sh:DN3d1dt0wnXfTH03oVmTee4KgmdNdB0NY3SuzA8Fwx8=
- name: Sync repository
uses: actions/checkout@v4
with:
persist-credentials: false
post-build-hook = /etc/nix/upload-to-cache.sh
- name: build
run: |

8
ci/upload-to-cache.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
# https://nix.dev/guides/recipes/post-build-hook.html#implementing-the-build-hook
set -eu
set -f # disable globbing
export IFS=' '
echo "Uploading paths" $OUT_PATHS
exec nix copy --to "s3://nixcache" $OUT_PATHS