-
Notifications
You must be signed in to change notification settings - Fork 47
91 lines (83 loc) · 2.97 KB
/
nix-ci.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
name: Nix CI
on:
push:
pull_request:
jobs:
check-hashes:
name: Ensure Nix Hashes are up-to-date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check if relevant files changed
shell: bash
run: |
# most sane regex
# checks if one of these files/directories has been touched
# - package.json
# - package-lock.json
# - nix/
# - composer.json
# - composer.lock
if [ -n "$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -P '^(?:package(?:-lock)?\.json$|nix\/|composer\.(?:json|lock)$')" ]; then
echo "File(s) changed so this job runs"
else
echo "no files changed so we exit neutrally (not success or failure)"
exit 78
fi
- name: Install nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
# - uses: cachix/cachix-action@v12
# with:
# name: trawelling
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Update generated files
run: nix develop --impure .#ci --command "update-nix-package-deps"
- name: Check if up-to-date
shell: bash
id: check
run: |
if [[ ! -z $(git status -s) ]]; then
git status
echo "up-to-date=false" >> "$GITHUB_OUTPUT"
fi
- name: Find Comment
uses: peter-evans/find-comment@v2
if: "github.event_name == 'pull_request' && steps.check.outputs.up-to-date == 'false'"
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: This comment was written by a bot!
- name: Create comment
if: "steps.fc.outputs.comment-id == '' && github.event_name == 'pull_request' && steps.check.outputs.up-to-date == 'false'"
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
The composer or npm dependencies are out of sync with the generated nix files.
Please update the files by either running the `update-nix-package-dep` script locally
or let GitHub actions do it by running `/nix-update`.
*This comment was written by a bot!* 🤖
- name: Fail Build
if: "steps.check.outputs.up-to-date == 'false'"
shell: bash
run: exit 1
build:
name: Build Package
runs-on: ubuntu-latest
needs:
- check-hashes
steps:
- uses: actions/checkout@v3
- name: Install nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
# - uses: cachix/cachix-action@v12
# with:
# name: trawelling
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build with nix
run: nix build