forked from Bos55/nix-config
feat(ci): implement automated deployment pipeline with deploy-rs
This commit is contained in:
parent
de1ee54b8b
commit
33fcc55bf5
17 changed files with 274 additions and 76 deletions
53
.github/workflows/build.yml
vendored
53
.github/workflows/build.yml
vendored
|
|
@ -1,43 +1,50 @@
|
|||
name: "Build"
|
||||
name: Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'test-*'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
determine-hosts:
|
||||
name: "Determining hosts to build"
|
||||
# Job to find all hosts that should be built
|
||||
get-hosts:
|
||||
runs-on: ubuntu-latest
|
||||
container: catthehacker/ubuntu:act-24.04
|
||||
outputs:
|
||||
hosts: ${{ steps.hosts.outputs.hostnames }}
|
||||
hosts: ${{ steps.set-hosts.outputs.hosts }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: https://github.com/cachix/install-nix-action@v31
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
- name: "Determine hosts"
|
||||
id: hosts
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v27
|
||||
- id: set-hosts
|
||||
run: |
|
||||
hostnames="$(nix eval .#nixosConfigurations --apply builtins.attrNames --json)"
|
||||
printf "hostnames=%s\n" "${hostnames}" >> "${GITHUB_OUTPUT}"
|
||||
# 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
|
||||
needs: determine-hosts
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
hostname: [
|
||||
Development,
|
||||
Testing
|
||||
]
|
||||
|
||||
host: ${{ fromJson(needs.get-hosts.outputs.hosts) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: https://github.com/cachix/install-nix-action@v31
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v27
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
- name: "Build host"
|
||||
- name: Build NixOS configuration
|
||||
run: |
|
||||
nix build ".#nixosConfigurations.${{ matrix.hostname }}.config.system.build.toplevel" --verbose
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue