-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (94 loc) · 3.65 KB
/
pr-closure-diff.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
name: NixOS closure diffs
on:
pull_request_target:
branches:
- main
jobs:
closure-diffs-comment:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Find potentially existing comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: NixOS closure diffs
- name: Set in-progress message
uses: peter-evans/create-or-update-comment@v4
id: create-or-update-comment
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
# NixOS closure diffs
Just a moment...
edit-mode: replace
- uses: actions/checkout@v4
with:
path: before
ref: ${{ github.event.pull_request.base.ref }}
- uses: actions/checkout@v4
with:
path: after
ref: ${{ github.event.pull_request.head.ref }}
- uses: cachix/install-nix-action@v27
with:
extra_nix_config: |
accept-flake-config = true
always-allow-substitutes = true
- run: |
nix flake show --refresh --all-systems --json ./before |
jq --raw-output '
path(.. | select(.type? == "nixos-configuration")) | .[1]
' |
sort > systems-before
cat systems-before
- run: |
nix flake show --refresh --all-systems --json ./after |
jq --raw-output '
path(.. | select(.type? == "nixos-configuration")) | .[1]
' |
sort > systems-after
cat systems-after
- run: printf '# NixOS closure diffs\n\n' > message-body
- run: |
printf 'Removed systems:\n```\n' >> message-body
comm -23 systems-before systems-after >> message-body
printf '```\n\n' >> message-body
- run: |
printf 'Added systems:\n```\n' >> message-body
comm -13 systems-before systems-after >> message-body
printf '```\n\n' >> message-body
- run: |
printf 'Changed systems:\n\n' >> message-body
comm -12 systems-before systems-after |
while read -r system; do
printf '<details>\n<summary>%s</summary>\n\n```\n' "$system" >> message-body
# The sed call filters out the control characters that diff-closures emits.
# See: https://github.com/NixOS/nix/issues/4626
nix store diff-closures --derivation \
"./before#nixosConfigurations.\"$system\".config.system.build.toplevel" \
"./after#nixosConfigurations.\"$system\".config.system.build.toplevel" |
sed 's/\x1b\[[0-9;]*m//g' >> message-body
printf '```\n</details>\n\n' >> message-body
done
- name: Set finished message
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.create-or-update-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: message-body
edit-mode: replace
- name: Set failure message
if: ${{ failure() }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.create-or-update-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
# NixOS closure diffs
Something went wrong. Please check the action log.
edit-mode: replace