feat: add push-nix-cache action, wire into deploy-static-site and build-static-server
Some checks failed
Build and Push static-server Image / build (push) Failing after 1m45s

Extracts sign+push logic into a reusable push-nix-cache action.
Both the site deploy and the image build now use it.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Christopher Mühl 2026-02-18 13:38:06 +01:00
parent 38792a985f
commit b094952455
No known key found for this signature in database
GPG key ID: 925AC7D69955293F
3 changed files with 47 additions and 8 deletions

View file

@ -21,6 +21,16 @@ jobs:
- name: Build static-server image - name: Build static-server image
run: nix build ./deploy-static-site/images#staticServer --out-link result-static-server run: nix build ./deploy-static-site/images#staticServer --out-link result-static-server
- name: Push Nix closure to S3 cache
if: env.NIX_SIGNING_KEY != ''
uses: https://git.toph.so/toph/ci-actions/push-nix-cache@main
with:
store-path: ./result-static-server
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }}
NIX_SIGNING_KEY: ${{ secrets.NIX_SIGNING_KEY }}
- name: Push to registry - name: Push to registry
run: | run: |
nix shell nixpkgs#skopeo -c skopeo copy \ nix shell nixpkgs#skopeo -c skopeo copy \

View file

@ -57,14 +57,11 @@ runs:
- name: Sign and push Nix closure to S3 cache - name: Sign and push Nix closure to S3 cache
if: env.NIX_SIGNING_KEY != '' if: env.NIX_SIGNING_KEY != ''
shell: bash uses: https://git.toph.so/toph/ci-actions/push-nix-cache@main
run: | with:
echo "${NIX_SIGNING_KEY}" > /tmp/nix-key store-path: ./result-site
nix store sign -k /tmp/nix-key --recursive ./result-site s3-endpoint: ${{ inputs.s3-endpoint }}
nix copy \ s3-bucket: ${{ inputs.s3-bucket }}
--to "s3://${{ inputs.s3-bucket }}?endpoint=${{ inputs.s3-endpoint }}&access-key-id=${AWS_ACCESS_KEY_ID}&secret-access-key=${AWS_SECRET_ACCESS_KEY}" \
./result-site
rm /tmp/nix-key
- name: Upload site tarball to S3 - name: Upload site tarball to S3
shell: bash shell: bash

View file

@ -0,0 +1,32 @@
name: Push Nix Cache
description: Sign a Nix store path and push it to the S3 binary cache
# Required env vars: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, NIX_SIGNING_KEY
inputs:
store-path:
description: 'Path to the Nix store symlink or derivation to push (e.g. ./result)'
required: true
s3-endpoint:
description: 'S3 endpoint URL'
required: false
default: 'https://s3.toph.so'
s3-bucket:
description: 'S3 bucket used as the Nix binary cache'
required: false
default: 'nix-cache'
runs:
using: composite
steps:
- name: Sign and push Nix closure
shell: bash
run: |
echo "${NIX_SIGNING_KEY}" > /tmp/nix-key
nix store sign -k /tmp/nix-key --recursive "${{ inputs.store-path }}"
nix copy \
--to "s3://${{ inputs.s3-bucket }}?endpoint=${{ inputs.s3-endpoint }}&access-key-id=${AWS_ACCESS_KEY_ID}&secret-access-key=${AWS_SECRET_ACCESS_KEY}" \
"${{ inputs.store-path }}"
rm /tmp/nix-key