-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsilver-flame-deploy.yaml
50 lines (48 loc) · 1.64 KB
/
silver-flame-deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Deploy NixOS System Configurations to Silver-Flame Hosts
on:
push:
branches: [ main ]
paths: [ 'homelab/local-hosts/silver-flame/**' ]
jobs:
deploy:
defaults:
run:
working-directory: homelab/local-hosts/silver-flame
runs-on: ubuntu-latest
steps:
- name: Checkout Jafner.net repo
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.RUNNER_GITHUB_TOKEN }}
nix_path: nixpkgs=channel:nixos-24.05
- name: Set up Cachix
uses: cachix/cachix-action@v15
with:
name: jafnernet # https://app.cachix.org/cache/jafnernet
authToken: '${{ secrets.CACHIX_TOKEN }}'
extraPullNames: nix-community
- name: Set up deploy-rs
run: nix build -o deploy github:serokell/deploy-rs#defaultPackage.x86_64-linux
- name: Set up SSH key
run: |
echo -e "${{ secrets.RUNNER_SSH_PRIVATEKEY }}" > /tmp/key
chmod 600 /tmp/key
- name: Derive host IPs
run: |
nix shell nixpkgs#nixfmt-rfc-style
nix-instantiate --parse flake.nix |\
nixfmt |\
grep 'hostname =' |\
cut -d'"' -f2 |\
xargs echo > /tmp/hostlist
- name: Add host keys to known_hosts
run: |
mkdir -p ~/.ssh && touch ~/.ssh/known_hosts && chmod 600 ~/.ssh/known_hosts
for host in $(cat /tmp/hostlist); do
ssh-keyscan -t ed25519 $host >> ~/.ssh/known_hosts
done
- name: Deploy
run: |
./deploy/bin/deploy --ssh-opts '-i /tmp/key'