forked from Bos55/nix-config
50 lines
1.4 KiB
YAML
50 lines
1.4 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- 'test-*'
|
|
pull_request:
|
|
|
|
jobs:
|
|
# Job to find all hosts that should be built
|
|
get-hosts:
|
|
runs-on: ubuntu-latest
|
|
container: catthehacker/ubuntu:act-24.04
|
|
outputs:
|
|
hosts: ${{ steps.set-hosts.outputs.hosts }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Nix
|
|
uses: cachix/install-nix-action@v27
|
|
- id: set-hosts
|
|
run: |
|
|
# Extract host names from nixosConfigurations
|
|
HOSTS=$(nix eval .#nixosConfigurations --apply "builtins.attrNames" --json)
|
|
echo "hosts=$HOSTS" >> $GITHUB_OUTPUT
|
|
|
|
build:
|
|
needs: get-hosts
|
|
runs-on: ubuntu-latest
|
|
container: catthehacker/ubuntu:act-24.04
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
host: ${{ fromJson(needs.get-hosts.outputs.hosts) }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Nix
|
|
uses: cachix/install-nix-action@v27
|
|
with:
|
|
nix_path: nixpkgs=channel:nixos-unstable
|
|
- name: Build NixOS configuration
|
|
run: |
|
|
nix build .#nixosConfigurations.${{ matrix.host }}.config.system.build.toplevel
|
|
- name: "Push to Attic"
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
run: |
|
|
nix profile install nixpkgs#attic-client
|
|
attic login homelab http://192.168.0.25:8080 "${{ secrets.ATTIC_TOKEN }}"
|
|
attic push homelab result
|
|
|