-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (84 loc) · 2.85 KB
/
pr.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
name: Comment diff in PR
permissions:
pull-requests: write
on:
workflow_dispatch:
pull_request:
paths:
- .github/workflows/**
- "**.nix"
- "flake.lock"
jobs:
build:
if: github.head_ref == 'update_flake_lock_action'
name: "Build ${{ matrix.target }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: william
- os: ubuntu-latest
target: nixos-local
- os: macos-latest
target: william-alt
- os: macos-latest
target: macos-local
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install nix
uses: cachix/install-nix-action@V27
with:
install_url: https://releases.nixos.org/nix/nix-2.18.2/install
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
accept-flake-config = true
- uses: cachix/cachix-action@v15
with:
name: williamhsieh
extraPullNames: nix-community
skipPush: true
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Free Disk Space (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: jlumbroso/free-disk-space@main
- name: Garbage collect build dependencies
run: nix-collect-garbage
- name: Fetch old system profile
run: nix build github:WilliamHsieh/dotfiles#top.${{ matrix.target }} -v --log-format raw --profile ./old-profile
- name: Add new system to profile
run: |
set -o pipefail
nix build .#top.${{ matrix.target }} --profile ./new-profile --show-trace --fallback -v --log-format raw > >(tee stdout.log) 2> >(tee /tmp/nix-build-err.log >&2)
- name: Output build failure
if: failure()
run: |
drv=$(grep "For full logs, run" /tmp/nix-build-err.log | grep -oE "/nix/store/.*.drv")
if [ -n $drv ]; then
nix log $drv
echo $drv
fi
exit 1
- name: Diff profile
id: diff
run: |
echo "diff<<EOF" >> "${GITHUB_OUTPUT}"
nix run nixpkgs#nvd diff ./old-profile ./new-profile >> "${GITHUB_OUTPUT}"
echo "EOF" >> "${GITHUB_OUTPUT}"
- name: Comment report in pr
uses: marocchino/sticky-pull-request-comment@v2
with:
hide_and_recreate: true
hide_classify: "OUTDATED"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: ".#top.${{ matrix.target }}"
message: |
### Report for `${{ matrix.target }}`
<details>
<summary> Version changes </summary> <br>
<pre> ${{ steps.diff.outputs.diff }} </pre>
</details>