-
Notifications
You must be signed in to change notification settings - Fork 11
191 lines (159 loc) · 5 KB
/
update.yml
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
---
name: Update ⬆️
'on':
schedule:
- cron: '30 3 * * 1,5' # At 03:30 on Monday, and Friday.
workflow_dispatch:
jobs:
update:
name: Update dependencies
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v10
- uses: DeterminateSystems/magic-nix-cache-action@v4
- uses: cachix/cachix-action@v14
with:
name: etu
extraPullNames: 'nix-community'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# Update flake
- name: Update flake inputs
run: 'nix flake update'
env:
github_token: '${{ secrets.GITHUB_TOKEN }}'
# Pre-fetch deps
- name: Pre-fetch deps
run: 'nix develop --command true'
env:
github_token: '${{ secrets.GITHUB_TOKEN }}'
# Do updates of nixpkgs and other dependencies.
- name: Update all dependencies
run: 'nix develop --command make update-all'
env:
github_token: '${{ secrets.GITHUB_TOKEN }}'
# Commit the updated dependencies to temporary branch
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'cron(treewide): Upgrade systems'
branch: tmp-updater-branch
create_branch: true
push_options: '--force'
cache:
name: Cache system
runs-on: ubuntu-22.04
needs: update
strategy:
matrix:
hostname:
- laptop-private-elis
- server-main-elis
- server-sparv
- vps04
- vps06
steps:
# Clone the code from the temporary branch
- uses: actions/checkout@v4
with:
ref: tmp-updater-branch
- uses: DeterminateSystems/nix-installer-action@v10
- uses: DeterminateSystems/magic-nix-cache-action@v4
- uses: cachix/cachix-action@v14
with:
name: etu
extraPullNames: 'nix-community'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# Build systems.
- name: Build system derivation
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 60
command: 'nix build .#nixosConfigurations.${{ matrix.hostname }}.config.system.build.toplevel'
cache-shell:
name: Cache nix shell
runs-on: ubuntu-22.04
needs: update
steps:
# Clone the code from the temporary branch
- uses: actions/checkout@v4
with:
ref: tmp-updater-branch
- uses: DeterminateSystems/nix-installer-action@v10
- uses: DeterminateSystems/magic-nix-cache-action@v4
- uses: cachix/cachix-action@v14
with:
name: etu
extraPullNames: 'nix-community'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Check the flake
run: 'nix build .#devShells.x86_64-linux.default'
check:
name: Check flake
runs-on: ubuntu-22.04
needs: cache
steps:
# Clone the code from the temporary branch
- uses: actions/checkout@v4
with:
ref: tmp-updater-branch
- uses: DeterminateSystems/nix-installer-action@v10
- uses: DeterminateSystems/magic-nix-cache-action@v4
- uses: cachix/cachix-action@v14
with:
name: etu
extraPullNames: 'nix-community'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Check the flake
run: 'nix flake check'
promote:
name: Promote to main branch
runs-on: ubuntu-22.04
needs: check
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Get remote branch data
run: 'git fetch'
- name: Get the tmp-updater-branch branch
run: 'git checkout tmp-updater-branch'
- name: Push temporary branch to main branch
run: 'git push origin tmp-updater-branch:main'
- name: Delete the temporary branch
run: 'git push origin --delete tmp-updater-branch'
deploy:
name: Deploy systems
runs-on: ubuntu-22.04
needs: promote
# Don't cancel jobs if one job fails
continue-on-error: true
strategy:
matrix:
hostname:
- server-main-elis
- server-sparv
- vps04
- vps06
steps:
- uses: actions/checkout@v4
- run: |
git pull
- uses: DeterminateSystems/nix-installer-action@v10
- uses: DeterminateSystems/magic-nix-cache-action@v4
# Build systems.
- name: Build system derivation
uses: nick-fields/retry@v3
with:
max_attempts: 2
timeout_minutes: 30
command: 'nix build .#nixosConfigurations.${{ matrix.hostname }}.config.system.build.toplevel'
# Configure SSH key
- uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
name: id_ed25519
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
# Deploy systems
- name: Deploy system
run: 'nix develop -c deploy --skip-checks --targets .#${{ matrix.hostname }}'