-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (67 loc) · 2.26 KB
/
Copy pathflake-diff.yml
File metadata and controls
79 lines (67 loc) · 2.26 KB
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
name: Flake Diff
on:
pull_request:
paths:
- 'nix/flake.lock'
permissions:
pull-requests: write
jobs:
diff:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v6
- name: Checkout base branch
uses: actions/checkout@v6
with:
ref: ${{ github.base_ref }}
path: base
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ github.token }}
- name: Build base profile
run: |
nix build ./base/nix#homeConfigurations.x86_64-linux.activationPackage --impure -o base-profile
env:
NIXPKGS_ALLOW_UNFREE: 1
- name: Build PR profile
run: |
nix build ./nix#homeConfigurations.x86_64-linux.activationPackage --impure -o pr-profile
env:
NIXPKGS_ALLOW_UNFREE: 1
- name: Generate diff with nvd
id: nvd
run: |
nix run 'nixpkgs#nvd' -- diff ./base-profile ./pr-profile > diff.txt 2>&1 || echo "No changes detected" > diff.txt
- name: Comment on PR
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const diff = fs.readFileSync('diff.txt', 'utf8');
const body = `## 📦 Package Diff\n\n\`\`\`\n${diff}\n\`\`\``;
const prNumber = context.payload.pull_request.number;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const botComment = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('Package Diff')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: body
});
}