diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b7cfd0..4319ce0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,15 +60,46 @@ jobs: server: ${{ fromJson(needs.parse-flake.outputs.servers) }} steps: - uses: actions/checkout@v5 + with: + fetch-depth: 0 - uses: cachix/install-nix-action@v31 with: extra_nix_config: experimental-features = nix-command flakes pipe-operators + - name: Check if build can be skipped + id: skip-check + env: + GH_TOKEN: ${{ github.token }} + run: | + last_sha=$(gh api \ + "repos/${{ github.repository }}/actions/workflows/ci.yml/runs?branch=main&status=success&per_page=1" \ + --jq '.workflow_runs[0].head_sha // empty') + + if [[ -z "$last_sha" ]]; then + echo "No previous successful run found, build required" + echo "skip=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + echo "Comparing current (${{ github.sha }}) with last successful ($last_sha)" + + current_drv=$(nix eval .#nixosConfigurations.${{ matrix.server }}.config.system.build.toplevel.drvPath --raw) + previous_drv=$(nix eval "git+file://$(pwd)?rev=$last_sha#nixosConfigurations.${{ matrix.server }}.config.system.build.toplevel.drvPath" --raw) + + if [[ "$current_drv" == "$previous_drv" ]]; then + echo "Derivations match, skipping build" + echo "skip=true" >> "$GITHUB_OUTPUT" + else + echo "Derivations differ, build required" + echo "skip=false" >> "$GITHUB_OUTPUT" + fi - uses: cachix/cachix-action@v15 + if: steps.skip-check.outputs.skip != 'true' with: name: sebastian-stork authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" useDaemon: false - name: Build server + if: steps.skip-check.outputs.skip != 'true' run: nix build .#nixosConfigurations.${{ matrix.server }}.config.system.build.toplevel --print-build-logs deploy: needs: [build-check, build-server] diff --git a/hosts/vps-ns/default.nix b/hosts/vps-ns/default.nix index 89f5724..701eb12 100644 --- a/hosts/vps-ns/default.nix +++ b/hosts/vps-ns/default.nix @@ -25,6 +25,7 @@ private-nameserver.enable = true; public-nameserver = { enable = true; + publicHostName = "ns1"; zones = [ "sprouted.cloud" "sstork.dev" diff --git a/hosts/vps-www/default.nix b/hosts/vps-www/default.nix index c2bac90..a9729eb 100644 --- a/hosts/vps-www/default.nix +++ b/hosts/vps-www/default.nix @@ -23,6 +23,7 @@ services.public-nameserver = { enable = true; + publicHostName = "ns2"; zones = [ "sprouted.cloud" "sstork.dev" diff --git a/modules/nixos/services/nameservers/public.nix b/modules/nixos/services/nameservers/public.nix index 702c4e4..fee45f1 100644 --- a/modules/nixos/services/nameservers/public.nix +++ b/modules/nixos/services/nameservers/public.nix @@ -40,7 +40,7 @@ let |> lib.attrValues |> lib.filter (host: host.config.custom.services.public-nameserver.enable) |> lib.map (host: { - name = host.config.custom.networking.hostName; + name = host.config.custom.services.public-nameserver.publicHostName; inherit (host.config.custom.networking.underlay) address; }); in @@ -66,6 +66,10 @@ in { options.custom.services.public-nameserver = { enable = lib.mkEnableOption ""; + publicHostName = lib.mkOption { + type = lib.types.nonEmptyStr; + default = netCfg.hostName; + }; port = lib.mkOption { type = lib.types.port; default = 53; diff --git a/modules/nixos/services/prometheus.nix b/modules/nixos/services/prometheus.nix index 99b4ba5..7409dea 100644 --- a/modules/nixos/services/prometheus.nix +++ b/modules/nixos/services/prometheus.nix @@ -104,12 +104,12 @@ in }; } { - alert = "CominDeploymentDifferentCommits"; + alert = "CominDeploymentCommitMismatch"; expr = "count(count by (commit_id) (comin_deployment_info)) > 1"; for = "10m"; annotations = { - summary = "Comin commit mismatch"; - description = "Two or more comin deployments are on different commits."; + summary = "Hosts are running different commits"; + description = "Not all hosts are running the same git commit, which may indicate a failed deployment and could lead to incompatible configurations."; }; } ];