Irrigation #52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Irrigation | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| generate-matrix: | |
| name: "Generate host matrix" | |
| runs-on: self-hosted | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Run flake checks | |
| run: nix flake check | |
| - name: List NixOS configurations | |
| id: set-matrix | |
| env: | |
| EXCLUDE_HOSTS: "zinnia" | |
| run: | | |
| exclude_pattern=$(echo "$EXCLUDE_HOSTS" | tr ',' '\n' | sed 's/^/^/; s/$/$/' | paste -sd'|' -) | |
| hosts=$(find nixosConfigurations -type f -name '*.nix' \ | |
| | sed -E 's|nixosConfigurations/||; s/\.nix$//' \ | |
| | grep -Ev "$exclude_pattern" \ | |
| | nix run nixpkgs#jq -- -R -s -c 'split("\n") | map(select(length > 0)) | {hostname: .}') | |
| echo "matrix=$hosts" | |
| echo "matrix=$hosts" >> $GITHUB_OUTPUT | |
| deploy: | |
| needs: generate-matrix | |
| name: Deploy system to ${{ matrix.hostname }} | |
| runs-on: self-hosted | |
| strategy: | |
| matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Deploy | |
| run: | | |
| nix shell nixpkgs#openssh nixpkgs#deploy-rs -c deploy --ssh-opts "-o StrictHostKeyChecking=no" -s .#${{ matrix.hostname }} |