-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (77 loc) · 2.53 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
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
name: Update inputs
on:
workflow_dispatch:
schedule:
- cron: 0 0 * * 1
jobs:
update:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.branch.outputs.branch }}
update_available: ${{ steps.changes.outputs.update_available }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install nix
uses: cachix/install-nix-action@v23
- name: Set branch name output
id: branch
run: echo "branch=ci/automatic-update-$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
- name: Create branch locally
run: git switch -c ${{ steps.branch.outputs.branch }}
- name: Setup git
run: |
git config --global user.email "tobias.happ@gmx.de"
git config --global user.name "Tobias Happ"
- name: Update inputs
run: |
nix \
--option commit-lockfile-summary 'flake.inputs: automatic update' \
flake update \
--commit-lock-file
- name: Check for changes
id: changes
run: |
if git diff --exit-code origin/master...; then
echo "update_available=false" >> $GITHUB_OUTPUT
else
echo "update_available=true" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.changes.outputs.update_available == 'true'
run: git push --force origin ${{ steps.branch.outputs.branch }}
build:
uses: ./.github/workflows/ci.yml
needs: update
if: needs.update.outputs.update_available == 'true'
with:
branch: ${{ needs.update.outputs.branch }}
secrets:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
merge:
runs-on: ubuntu-latest
needs:
- update
- build
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if update branch is behind master
run: git diff origin/${{ needs.update.outputs.branch }}...origin/master --exit-code
- name: Merge update into master
run: git merge origin/${{ needs.update.outputs.branch }}
- name: Push master
run: git push origin master
- name: Delete update branch
run: git push --delete origin ${{ needs.update.outputs.branch }}
# needed for cachix agent deployments
final-build:
uses: ./.github/workflows/ci.yml
needs: merge
secrets:
CACHIX_ACTIVATE_TOKEN: ${{ secrets.CACHIX_ACTIVATE_TOKEN }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}