38 lines
1.1 KiB
YAML
38 lines
1.1 KiB
YAML
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout repo
|
|
uses: actions/checkout@v6
|
|
- name: install necessary packages
|
|
run: |
|
|
set -e
|
|
apt update
|
|
apt install rsync -y
|
|
- name: add ssh key
|
|
run: |
|
|
set -e
|
|
mkdir -p /root/.ssh
|
|
ssh-keyscan toufy.me > /root/.ssh/known_hosts
|
|
echo "${{ secrets.SSH_KEY }}" | tr -d "\r" > /root/.ssh/id_ed25519
|
|
chmod -R 600 /root/.ssh
|
|
echo "pubkey: "
|
|
ssh-keygen -y -f /root/.ssh/id_ed25519
|
|
- name: copy repo to target
|
|
run: rsync -az . root@toufy.me:/tmp/deploy
|
|
- name: nixos-rebuild test
|
|
run: |
|
|
set -e
|
|
ssh root@toufy.me -C "nixos-rebuild test --flake /tmp/deploy --impure"
|
|
[ "$?" == 0 ] || exit 1
|
|
- name: nixos-rebuild switch
|
|
run: |
|
|
set -e
|
|
ssh root@toufy.me -C "nixos-rebuild switch --flake /tmp/deploy --impure"
|
|
[ "$?" == 0 ] || exit 1
|
|
- name: clean up
|
|
run: ssh root@toufy.me -C "rm -rf /tmp/deploy"
|