try putting everything in one workflow cause gitea doesn't support running the 2nd after the 1st
This commit is contained in:
parent
8676253432
commit
ade07ccd6f
@ -1,19 +0,0 @@
|
|||||||
name: nix flake show
|
|
||||||
run-name: ${{ gitea.actor }} pushed to repo. Checking config syntax.
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
show-flake:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install Nix
|
|
||||||
uses: cachix/install-nix-action@v31
|
|
||||||
|
|
||||||
- name: Run nix flake show
|
|
||||||
run: |
|
|
||||||
echo "Running nix flake show..."
|
|
||||||
nix flake show --show-trace
|
|
||||||
@ -1,17 +1,25 @@
|
|||||||
name: rebuild server1
|
name: nixos config pipeline
|
||||||
run-name: ${{ gitea.actor }} triggered server1 rebuild
|
|
||||||
|
|
||||||
on:
|
on: [push]
|
||||||
workflow_run:
|
|
||||||
workflows: ["nix flake show"]
|
|
||||||
types:
|
|
||||||
- completed
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
show-flake:
|
||||||
if: ${{ gitea.event.workflow_run.conclusion == 'success' }}
|
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: ssh to server1 and rebuild
|
- name: ssh to server1 and rebuild
|
||||||
uses: appleboy/ssh-action@v1.2.0
|
uses: appleboy/ssh-action@v1.2.0
|
||||||
@ -21,19 +29,16 @@ jobs:
|
|||||||
key: ${{ secrets.SERVER1_KEY }}
|
key: ${{ secrets.SERVER1_KEY }}
|
||||||
script: |
|
script: |
|
||||||
set -e
|
set -e
|
||||||
echo "Pulling repo ..."
|
|
||||||
cd /home/smayzy/nix-config
|
cd /home/smayzy/nix-config
|
||||||
git pull
|
git pull
|
||||||
echo "Rebuilding system ..."
|
|
||||||
old_gen="$(readlink /run/current-system)"
|
old_gen="$(readlink /run/current-system)"
|
||||||
if nixos-rebuild switch --flake .#server1 --show-trace; then
|
if nixos-rebuild switch --flake .#server1 --show-trace; then
|
||||||
echo "Deployment successful"
|
echo "Deployment successful"
|
||||||
else
|
else
|
||||||
if [ "$(readlink /run/current-system)" != "$old_gen" ]; then
|
new_gen="$(readlink /run/current-system)"
|
||||||
echo "Build failed after activation — rolling back..."
|
if [ "$new_gen" != "$old_gen" ]; then
|
||||||
nixos-rebuild switch --rollback
|
nixos-rebuild switch --rollback
|
||||||
else
|
|
||||||
echo "Build failed before activation — staying on current config"
|
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user