try putting everything in one workflow cause gitea doesn't support running the 2nd after the 1st
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
name: nixos config pipeline
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
show-flake:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
check-success: ${{ steps.check.outcome == 'success' }}
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
- id: check
|
||||
name: Run nix flake show
|
||||
run: nix flake show --show-trace
|
||||
|
||||
deploy:
|
||||
needs: show-flake
|
||||
if: needs.show-flake.result == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: ssh to server1 and rebuild
|
||||
uses: appleboy/ssh-action@v1.2.0
|
||||
with:
|
||||
host: ${{ secrets.SERVER1_HOST }}
|
||||
username: root
|
||||
key: ${{ secrets.SERVER1_KEY }}
|
||||
script: |
|
||||
set -e
|
||||
cd /home/smayzy/nix-config
|
||||
git pull
|
||||
old_gen="$(readlink /run/current-system)"
|
||||
if nixos-rebuild switch --flake .#server1 --show-trace; then
|
||||
echo "Deployment successful"
|
||||
else
|
||||
new_gen="$(readlink /run/current-system)"
|
||||
if [ "$new_gen" != "$old_gen" ]; then
|
||||
nixos-rebuild switch --rollback
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user