-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (235 loc) · 8.84 KB
/
updater.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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
name: "Flake updater"
on:
# schedule:
# - cron: "0 0 * * *"
workflow_dispatch: # allow manual triggering
pull_request:
push:
jobs:
# update_homes:
# strategy:
# matrix:
# pair:
# # - machine: "appaquet@deskapp"
# # os: ubuntu-latest
# - machine: "appaquet@servapp"
# os: ubuntu-latest
# # - machine: "appaquet@mbpapp"
# # os: macos-latest
# runs-on: ${{ matrix.pair.os }}
# steps:
# - uses: actions/checkout@v4
# - uses: DeterminateSystems/nix-installer-action@main
# with:
# extra-conf: |
# experimental-features = nix-command flakes
# access-tokens = github.com=${{ secrets.GH_PAT }}
# github-token: ${{ secrets.GH_PAT }}
# - name: Add & update nixpkgs channel
# run: |
# nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs
# nix-channel --update nixpkgs
# nix profile install nixpkgs#nvd
# - name: Building Home Manager baseline...
# run: |
# set -xe
# MACHINE_KEY="${{ matrix.pair.machine }}" ./x home build
# mv result result-before
# - name: Update flakes
# run: |
# set -xe
# nix flake update
# - name: Building Home Manager new
# run: |
# set -xe
# MACHINE_KEY="${{ matrix.pair.machine }}" ./x home build
# mv result result-after
# - name: Diffing...
# run: |
# set -xe
# nvd diff result-before result-after | tee diff
# # Only include if significant changes. Ex base output:
# # <<< result-before
# # >>> result-after
# # Version changes:
# # Closure size: 716 -> 716 (10 paths added, 10 paths removed, delta +0, disk usage +287.0KiB).
# NB_CHANGES=$(grep -vcE "(Version changes|Closure size|<<<|>>>)" diff || true)
# if [ $NB_CHANGES -gt 0 ]; then
# echo "Changes for ${{ matrix.pair.machine }} home:" > diff-out
# cat diff >> diff-out
# echo "\n" >> diff-out
# cat diff-out > "${{ matrix.pair.machine }}-home-diff"
# fi
# - name: Add diff as artifact
# uses: actions/upload-artifact@v4
# with:
# name: "${{ matrix.pair.machine }}-home-diff"
# path: "${{ matrix.pair.machine }}-home-diff"
# if-no-files-found: ignore # no files means no diff
# - name: Add flake.lock
# uses: actions/upload-artifact@v4
# with:
# name: "${{ matrix.pair.machine }}-flake"
# path: "flake.lock"
# update_nixos:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# machine: ["appaquet@deskapp"]
# steps:
# - uses: actions/checkout@v4
# - uses: DeterminateSystems/nix-installer-action@main
# with:
# extra-conf: |
# experimental-features = nix-command flakes
# access-tokens = github.com=${{ secrets.GH_PAT }}
# github-token: ${{ secrets.GH_PAT }}
# - name: Add & update nixpkgs channel
# run: |
# nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs
# nix-channel --update nixpkgs
# nix profile install nixpkgs#nixos-rebuild nixpkgs#nvd
# - name: Building NixOS baseline...
# run: |
# set -xe
# MACHINE_KEY="appaquet@deskapp" ./x nixos build
# mv result result-before
# - name: Update flakes
# run: |
# set -xe
# nix flake update
# - name: Building NixOS new
# run: |
# set -xe
# MACHINE_KEY="appaquet@deskapp" ./x nixos build
# mv result result-after
# - name: Diffing...
# run: |
# set -xe
# nvd diff result-before result-after | tee diff
# # Only include if significant changes. Ex base output:
# # <<< result-before
# # >>> result-after
# # Version changes:
# # [U.] #1 nixos-system-deskapp 24.05.20240928.fbca5e7 -> 24.05.20240930.1719f27
# # Closure size: 1637 -> 1637 (29 paths added, 29 paths removed, delta +0, disk usage +7.5KiB).
# NB_CHANGES=$(grep -vcE "(Version changes|nixos-system|Closure size|<<<|>>>)" diff || true)
# if [ $NB_CHANGES -gt 0 ]; then
# echo "Changes for ${{ matrix.machine }} nixos:" > diff-out
# cat diff >> diff-out
# echo "\n" >> diff-out
# cat diff-out > "${{ matrix.machine }}-nixos-diff"
# fi
# - name: Add as artifact
# uses: actions/upload-artifact@v4
# with:
# name: "${{ matrix.machine }}-nixos-diff"
# path: "${{ matrix.machine }}-nixos-diff"
# if-no-files-found: ignore # no files means no diff
# update_darwin:
# runs-on: macos-latest
# strategy:
# matrix:
# machine: ["appaquet@mbpapp"]
# steps:
# - uses: actions/checkout@v4
# - uses: DeterminateSystems/nix-installer-action@main
# with:
# extra-conf: |
# experimental-features = nix-command flakes
# access-tokens = github.com=${{ secrets.GH_PAT }}
# github-token: ${{ secrets.GH_PAT }}
# - name: Add & update nixpkgs channel
# run: |
# nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs
# nix-channel --update nixpkgs
# nix profile install nixpkgs#nvd
# - name: Building baseline...
# run: |
# set -xe
# MACHINE_KEY="${{ matrix.machine }}" ./x darwin build
# mv result darwin-result-before
# - name: Update flakes
# run: |
# set -xe
# nix flake update
# - name: Building new...
# run: |
# set -xe
# MACHINE_KEY="${{ matrix.machine }}" ./x darwin build
# mv result darwin-result-after
# - name: Diffing...
# run: |
# set -xe
# nvd diff ./darwin-result-before ./darwin-result-after | tee diff
# # Only include if significant changes. Ex base output:
# # <<< result-before
# # >>> result-after
# # Version changes:
# # [C.] #1 darwin-system 24.05pre-git+darwin4.4b43b68, 24.05pre-git+darwin5 -> 24.05pre-git+darwin4.f61d5f2, 24.05pre-git+darwin5
# # Closure size: 169 -> 169 (10 paths added, 10 paths removed, delta +0, disk usage +3.7KiB).
# NB_CHANGES=$(grep -vcE "(Version changes|darwin-system|Closure size|<<<|>>>)" diff || true)
# if [ $NB_CHANGES -gt 0 ]; then
# echo "Changes for ${{ matrix.machine }} darwin:" > diff-out
# cat diff >> diff-out
# echo "\n" >> diff-out
# cat diff-out > "${{ matrix.machine }}-darwin-diff"
# fi
# - name: Add as artifact
# uses: actions/upload-artifact@v4
# with:
# name: "${{ matrix.machine }}-darwin-diff"
# path: "${{ matrix.machine }}-darwin-diff"
# if-no-files-found: ignore # no files means no diff
incoming:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create PR
run: |
echo "something" > diff
- name: Add as artifact
uses: actions/upload-artifact@v4
with:
name: diff
path: diff
if-no-files-found: ignore # no files means no diff
create_pr:
runs-on: ubuntu-latest
# needs: [update_homes, update_nixos, update_darwin]
needs: [incoming]
steps:
- uses: actions/checkout@v4
- name: Fetch all artifacts
uses: actions/download-artifact@v4
with:
path: diffs
- name: Create PR
run: |
set -xe
BRANCH_NAME="update-flake"
# Check if pr exists, delete it if it does
EXISTS=$(gh pr view $BRANCH_NAME 2>&1 | grep -cv "no pull" || true)
if [ $EXISTS -gt 0 ]; then
echo "PR exists, deleting it"
gh pr close $BRANCH_NAME --delete-branch
fi
if [ -z "$(ls -A diffs)" ]; then
echo "No diffs found, exiting"
exit 0
fi
cat diffs/*/* > all-diffs
if [ -z "$(cat all-diffs)" ]; then
echo "No diffs found, exiting"
exit 0
fi
git config --global user.email "[email protected]"
git config --global user.name "Andre-Philippe Paquet"
git branch -D $BRANCH_NAME || true
git checkout -b $BRANCH_NAME
git add flake.lock
git commit -m "chore(deps): update flake lock"
git push origin $BRANCH_NAME
gh pr create --title "Flake update" --body "$(cat all-diffs)" --base master --head "$BRANCH_NAME"
env:
GH_TOKEN: ${{ secrets.GH_PAT }}