-
Notifications
You must be signed in to change notification settings - Fork 13
60 lines (59 loc) · 1.93 KB
/
update.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
name: "Update dependencies and sources"
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
env:
OLD_HASH: "Unknown"
NEW_HASH: "Unknown"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0
- name: Install nixFlake
uses: cachix/install-nix-action@v20
with:
install_url: https://github.com/numtide/nix-unstable-installer/releases/latest/download/install
extra_nix_config: |
experimental-features = nix-command flakes
- name: Configure git
run: |
git config --global user.name 'Automation - Ninlives'
git config --global user.email '[email protected]'
- uses: cachix/cachix-action@v12
with:
name: nixos-cn
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Update dependencies
run: nix flake update
- name: Commit if build succeed
run: |
git diff-index --quiet HEAD \
|| (nix flake check && git commit -am "Update dependencies - Automated Commit" && git push || git stash)
- name: Update registries
run: |
echo "OLD_HASH=$(nix run .#re-export-hash)" >> $GITHUB_ENV
nix run .#update-lock > registries.lock.new
rm registries.lock
mv registries.lock.new registries.lock
echo "NEW_HASH=$(nix run .#re-export-hash)" >> $GITHUB_ENV
- name: Commit if build succeed
run: |
echo OLD_HASH is ${OLD_HASH}
echo NEW_HASH is ${NEW_HASH}
git diff-index --quiet HEAD || if [[ "${NEW_HASH}" != "${OLD_HASH}" ]];then
nix flake check \
&& git commit -am "Update registries - Automated Commit" && git push \
|| git stash
else
git stash
fi
- name: Update packages
run: |
nix run .#update-packages
git push || true