blob: 3d1834d4f1525a7605fb22b34939d6e5baa93946 (
plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
|
name: Update Nix dependencies
on:
workflow_dispatch:
schedule:
# Every Monday at 06:00 UTC
- cron: "0 6 * * 1"
permissions:
contents: write
pull-requests: write
jobs:
update-deps:
runs-on: ubuntu-latest
env:
FLAKE_PATH: .
NPINS_DIR: .
UPDATE_BRANCH: ci/update-nix-deps
COMMIT_AUTHOR_NAME: "github-actions[bot]"
COMMIT_AUTHOR_EMAIL: "62766066+github-actions[bot]@users.noreply.github.com" # FIXME: this is my user ID
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0
persist-credentials: false
- name: Install Nix
uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
- name: Show Nix version
run: nix --version
- name: Create or switch update branch
run: |
BASE_BRANCH="${GITHUB_REF_NAME#refs/heads/}"
if git rev-parse --verify "$UPDATE_BRANCH" >/dev/null 2>&1; then
git checkout "$UPDATE_BRANCH"
git rebase "origin/${BASE_BRANCH}"
else
git checkout -b "$UPDATE_BRANCH" "origin/${BASE_BRANCH}"
fi
- name: Configure Git author
run: |
git config user.name "${COMMIT_AUTHOR_NAME}"
git config user.email "${COMMIT_AUTHOR_EMAIL}"
- name: Update flake inputs
working-directory: ${{ env.FLAKE_PATH }}
run: |
if [ -f flake.nix ]; then
nix flake update
else
echo "No flake.nix found at $PWD, skipping flake update"
fi
- name: Update npins
working-directory: ${{ env.NPINS_DIR }}
run: |
if [ -f sources.json ] || [ -d npins ]; then
nix shell nixpkgs#npins --command npins update
else
echo "No npins configuration detected at $PWD, skipping npins update"
fi
- name: Check for changes
id: diff
run: |
git status --porcelain
if [ -z "$(git status --porcelain)" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit changes
if: steps.diff.outputs.changed == 'true'
run: |
git add -A
git commit -m "ci: update dependencies"
- name: Push changes
if: steps.diff.outputs.changed == 'true'
run: |
git push --set-upstream origin "$UPDATE_BRANCH"
- name: Create or update pull request
if: steps.diff.outputs.changed == 'true'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1
with:
branch: ${{ env.UPDATE_BRANCH }}
title: "ci: update Nix dependencies"
body: |
Automated update of:
- Flake inputs via `nix flake update`
- npins sources via `npins update`
This PR was created by GitHub Actions. CI must pass before merging.
commit-message: "ci: update Nix dependencies"
signoff: false
delete-branch: false
|