infra/.forgejo/workflows/build-pi-img.yml

49 lines
1.4 KiB
YAML
Raw Normal View History

2023-08-03 11:54:15 +01:00
name: Build Pi NixOS Image
on:
push:
paths:
- 'pi-imgs/**'
2023-08-16 21:41:19 +01:00
- '.forgejo/workflows/build-pi-img.yml'
2023-08-03 13:41:27 +01:00
2023-08-03 11:54:15 +01:00
jobs:
sync:
runs-on: debian-latest-arm
steps:
- name: Checkout code
uses: actions/checkout@v3.5.3
2023-08-03 11:54:15 +01:00
with:
ref: trunk
2023-08-15 21:35:42 +01:00
- name: "Cache Nix store"
uses: actions/cache@v3.0.8
id: nix-cache
with:
path: /tmp/nixcache
key: "pi-nix-cache-v1"
2023-08-03 11:54:15 +01:00
- name: Install prerequisites
2023-08-15 18:48:24 +01:00
run: apt update && apt install -y sudo zstd
2023-08-03 11:54:15 +01:00
- name: Install Nix
uses: https://github.com/cachix/install-nix-action@v22
with:
extra_nix_config: "experimental-features = nix-command flakes"
nix_path: nixpkgs=channel:nixos-23.05
- name: Remove access_tokens
run: sed -i '/^access-tokens/d' /etc/nix/nix.conf
2023-08-15 18:30:00 +01:00
2023-08-15 21:35:42 +01:00
- name: "Import Nix store cache"
if: "steps.nix-cache.outputs.cache-hit == 'true'"
run: "nix-store --import < /tmp/nixcache"
2023-08-15 18:30:00 +01:00
2023-08-03 11:54:15 +01:00
- name: Build image
2023-09-05 17:16:10 +01:00
run: nix build .#packages.aarch64-linux.raspberry-pi
2023-08-15 21:30:43 +01:00
- uses: https://github.com/actions/upload-artifact@v3.1.2
2023-08-03 11:54:15 +01:00
with:
2023-08-15 22:49:37 +01:00
name: nixos-pi-23.05-${{ env.GITHUB_SHA }}.img
2023-08-03 12:35:22 +01:00
path: result/sd-image/*.img
2023-08-15 18:30:00 +01:00
2023-08-15 21:35:42 +01:00
- name: "Export Nix store cache"
if: "steps.nix-cache.outputs.cache-hit != 'true'"
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"