tangled
alpha
login
or
join now
dunkirk.sh
/
dots
3
fork
atom
Kieran's opinionated (and probably slightly dumb) nix config
3
fork
atom
overview
issues
pulls
pipelines
feat: update the nixos deployment workflow
dunkirk.sh
3 weeks ago
d97853c3
9d205408
verified
This commit was signed with the committer's
known signature
.
dunkirk.sh
SSH Key Fingerprint:
SHA256:DqcG0RXYExE26KiWo3VxJnsxswN1QNfTBvB+bdSpk80=
+99
-9
1 changed file
expand all
collapse all
unified
split
.github
workflows
deploy.yaml
+99
-9
.github/workflows/deploy.yaml
reviewed
···
7
7
workflow_dispatch:
8
8
9
9
jobs:
10
10
+
pre-deploy:
11
11
+
runs-on: ubuntu-latest
12
12
+
outputs:
13
13
+
generations: ${{ steps.capture.outputs.generations }}
14
14
+
15
15
+
steps:
16
16
+
- name: Setup Tailscale
17
17
+
uses: tailscale/github-action@v3
18
18
+
with:
19
19
+
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
20
20
+
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
21
21
+
tags: tag:deploy
22
22
+
use-cache: "true"
23
23
+
24
24
+
- name: Configure SSH
25
25
+
run: |
26
26
+
mkdir -p ~/.ssh
27
27
+
echo "StrictHostKeyChecking accept-new" >> ~/.ssh/config
28
28
+
29
29
+
- name: Capture generations
30
30
+
id: capture
31
31
+
run: |
32
32
+
GENERATIONS='{}'
33
33
+
for NODE in terebithia; do
34
34
+
GEN=$(ssh kierank@${NODE} \
35
35
+
"readlink /nix/var/nix/profiles/system | grep -oP 'system-\K[0-9]+'")
36
36
+
GENERATIONS=$(echo "$GENERATIONS" | jq -c --arg node "$NODE" --arg gen "$GEN" '. + {($node): $gen}')
37
37
+
done
38
38
+
echo "generations=$GENERATIONS" >> "$GITHUB_OUTPUT"
39
39
+
10
40
deploy:
41
41
+
needs: pre-deploy
42
42
+
strategy:
43
43
+
fail-fast: false
44
44
+
matrix:
45
45
+
node:
46
46
+
- name: terebithia
47
47
+
arch: aarch64-linux
48
48
+
49
49
+
name: ${{ matrix.node.name }}
11
50
runs-on: ubuntu-latest
51
51
+
environment:
52
52
+
name: ${{ matrix.node.name }}
53
53
+
54
54
+
concurrency:
55
55
+
group: deploy-${{ matrix.node.name }}
56
56
+
cancel-in-progress: false
57
57
+
12
58
steps:
13
59
- uses: actions/checkout@v4
14
60
···
19
65
extra-platforms = aarch64-linux
20
66
21
67
- name: Set up QEMU
68
68
+
if: matrix.node.arch == 'aarch64-linux'
22
69
uses: docker/setup-qemu-action@v3
23
70
with:
24
71
platforms: arm64
···
36
83
mkdir -p ~/.ssh
37
84
echo "StrictHostKeyChecking accept-new" >> ~/.ssh/config
38
85
86
86
+
- name: Deploy ${{ matrix.node.name }}
87
87
+
run: |
88
88
+
nix run 'github:serokell/deploy-rs' -- \
89
89
+
--skip-checks \
90
90
+
--remote-build \
91
91
+
--ssh-user kierank \
92
92
+
--ssh-opts="-o StrictHostKeyChecking=accept-new" \
93
93
+
.#${{ matrix.node.name }}
94
94
+
95
95
+
rollback:
96
96
+
needs: [pre-deploy, deploy]
97
97
+
if: failure()
98
98
+
runs-on: ubuntu-latest
99
99
+
100
100
+
steps:
101
101
+
- name: Setup Tailscale
102
102
+
uses: tailscale/github-action@v3
103
103
+
with:
104
104
+
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
105
105
+
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
106
106
+
tags: tag:deploy
107
107
+
use-cache: "true"
108
108
+
109
109
+
- name: Configure SSH
110
110
+
run: |
111
111
+
mkdir -p ~/.ssh
112
112
+
echo "StrictHostKeyChecking accept-new" >> ~/.ssh/config
113
113
+
114
114
+
- name: Rollback all nodes
115
115
+
env:
116
116
+
GENERATIONS: ${{ needs.pre-deploy.outputs.generations }}
117
117
+
run: |
118
118
+
echo "$GENERATIONS" | jq -r 'to_entries[] | "\(.key) \(.value)"' | \
119
119
+
while read -r NODE GEN; do
120
120
+
echo "::group::rollback $NODE → generation $GEN"
121
121
+
ssh kierank@${NODE} "
122
122
+
sudo nix-env -p /nix/var/nix/profiles/system --switch-generation ${GEN}
123
123
+
sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
124
124
+
"
125
125
+
echo "::endgroup::"
126
126
+
done
127
127
+
128
128
+
docs:
129
129
+
needs: deploy
130
130
+
runs-on: ubuntu-latest
131
131
+
132
132
+
steps:
133
133
+
- uses: actions/checkout@v4
134
134
+
135
135
+
- name: Install Nix
136
136
+
uses: DeterminateSystems/determinate-nix-action@main
137
137
+
39
138
- name: Build docs
40
139
run: nix build .#packages.x86_64-linux.docs -L
41
140
···
45
144
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
46
145
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
47
146
command: pages deploy result --project-name=dots-docs
48
48
-
49
49
-
- name: Deploy all configurations
50
50
-
run: |
51
51
-
nix run 'github:serokell/deploy-rs' -- \
52
52
-
--skip-checks \
53
53
-
--remote-build \
54
54
-
--ssh-user kierank \
55
55
-
--ssh-opts="-o StrictHostKeyChecking=accept-new" \
56
56
-
.