-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (60 loc) · 1.97 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
name: Update inputs
on:
schedule:
- cron: 0 0 * * *
jobs:
update:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.branch.outputs.branch }}
update_available: ${{ steps.commit.outputs.changes_detected }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install nix
uses: cachix/install-nix-action@v18
- uses: cachix/cachix-action@v12
with:
name: christianharke
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Update inputs
run: nix flake update
- name: Set branch name output
id: branch
run: echo "::set-output name=branch::ci/automatic-update-$(date +%Y-%m-%d)"
- name: Create branch locally
run: git switch -c ${{ steps.branch.outputs.branch }}
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
id: commit
with:
commit_author: Christian Harke <[email protected]>
commit_message: "flake.inputs: automatic update"
branch: ${{ steps.branch.outputs.branch }}
push_options: --force
build:
uses: christianharke/nixcfg/.github/workflows/ci.yml@master
needs: update
if: needs.update.outputs.update_available == 'true'
with:
branch: ${{ needs.update.outputs.branch }}
merge:
runs-on: ubuntu-latest
needs:
- update
- build
steps:
- name: Checkout repository
uses: actions/checkout@v2
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 }}