-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (73 loc) · 2.38 KB
/
update-hash.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
name: Update Hash
on:
workflow_dispatch:
schedule:
- cron: "0 */4 * * *"
env:
BRANCH: update-${{ github.run_number }}
jobs:
get-update-scripts:
runs-on: ubuntu-latest
outputs:
update-scripts: ${{ steps.get-update-scripts.outputs.update-scripts }}
steps:
- uses: actions/checkout@v4
- name: Get update scripts
id: get-update-scripts
shell: bash # Set pipefail
run: echo "update-scripts=$(find . -name "update.sh" | jq -cnR '[inputs]')" >> "$GITHUB_OUTPUT"
update:
runs-on: ubuntu-latest
needs: get-update-scripts
strategy:
fail-fast: false
matrix:
update-script: ${{ fromJson(needs.get-update-scripts.outputs.update-scripts) }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: experimental-features = nix-command flakes
- name: Run update script
continue-on-error: true
run: |-
${{ matrix.update-script }}
git stash
git pull
git stash pop
- uses: stefanzweifel/git-auto-commit-action@v5
continue-on-error: true
with:
commit_message: |
pkgs: autoupdate
uwu
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
branch: ${{ env.BRANCH }}
push_options: --atomic
create_branch: true
squash-to-master:
if: always()
runs-on: ubuntu-latest
needs: update
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.UPDATE_HASH_TOKEN }}
- name: Check if branch exists
id: check-branch
run: '! git branch -r | grep $BRANCH; echo exists=$? >> "$GITHUB_OUTPUT"'
- name: Squash commits to master
if: steps.check-branch.outputs.exists == '1'
run: git merge --squash origin/$BRANCH
- uses: stefanzweifel/git-auto-commit-action@v5
if: steps.check-branch.outputs.exists == '1'
with:
commit_message: |
pkgs: autoupdate
uwu
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- name: Delete temporary branch
if: always() && steps.check-branch.outputs.exists == '1'
run: git push origin -d $BRANCH