-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (113 loc) · 4.36 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Auto Update
on:
#schedule:
# - cron: '0 0 * * *'
workflow_dispatch:
env:
REF_CORE: development-v6
REF_WEB: development-v6
REF_FTL: development-v6
# @TODO when v6 is released these should be set to master
jobs:
check:
concurrency: check
runs-on: ubuntu-latest
continue-on-error: true
outputs:
CORE_HASH: ${{ steps.new-hashes.outputs.CORE_HASH }}
WEB_HASH: ${{ steps.new-hashes.outputs.WEB_HASH }}
FTL_HASH: ${{ steps.new-hashes.outputs.FTL_HASH }}
steps:
- name: Checkout own repository
uses: actions/checkout@v4
- name: Checkout pi-hole/pi-hole repository
uses: actions/checkout@v4
with:
repository: pi-hole/pi-hole
ref: ${{ env.REF_CORE }}
path: ./dev/core
- name: Checkout pi-hole/web repository
uses: actions/checkout@v4
with:
repository: pi-hole/web
ref: ${{ env.REF_WEB }}
path: ./dev/web
- name: Checkout pi-hole/FTL repository
uses: actions/checkout@v4
with:
repository: pi-hole/FTL
ref: ${{ env.REF_FTL }}
path: ./dev/FTL
- name: Set old hashes
id: old-hashes
run: |
echo "CORE_HASH=$(sed -n "s/^ REF_CORE: \([[:alnum:]_-]*\).*$/\1/p" ./.github/workflows/build.yml)" >> $GITHUB_OUTPUT
echo "WEB_HASH=$(sed -n "s/^ REF_WEB: \([[:alnum:]_-]*\).*$/\1/p" ./.github/workflows/build.yml)" >> $GITHUB_OUTPUT
echo "FTL_HASH=$(sed -n "s/^ REF_FTL: \([[:alnum:]_-]*\).*$/\1/p" ./.github/workflows/build.yml)" >> $GITHUB_OUTPUT
- name: Set new hashes
id: new-hashes
run: |
echo "CORE_HASH=$(git -C "./dev/core" rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
echo "WEB_HASH=$(git -C "./dev/web" rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
echo "FTL_HASH=$(git -C "./dev/FTL" rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
- name: Hashes for pi-hole/pi-hole are different
if: ${{ steps.old-hashes.outputs.CORE_HASH == steps.new-hashes.outputs.CORE_HASH }}
run: exit 1
- name: Hashes for pi-hole/web are different
if: ${{ steps.old-hashes.outputs.WEB_HASH == steps.new-hashes.outputs.WEB_HASH }}
run: exit 1
- name: Hashes for pi-hole/FTL are different
if: ${{ steps.old-hashes.outputs.FTL_HASH == steps.new-hashes.outputs.FTL_HASH }}
run: exit 1
- name: Apply patches (core)
id: patch-core
uses: ./.github/actions/patch
with:
patches_prefix: core
git_path: ./dev/core
- name: Apply patches (web)
id: patch-web
uses: ./.github/actions/patch
with:
patches_prefix: web
git_path: ./dev/web
- name: Apply patches (FTL)
id: patch-FTL
uses: ./.github/actions/patch
with:
patches_prefix: FTL
git_path: ./dev/FTL
update:
concurrency: update
needs: [check]
if: ${{ needs.check.result == 'success' }}
runs-on: ubuntu-latest
continue-on-error: true
#permissions:
# contents: write
steps:
- name: Checkout own repository
uses: actions/checkout@v4
- name: Replace refs in build workflow
run: |
sed 's/ REF_CORE:.*$/ REF_CORE: ${{ needs.check.outputs.CORE_HASH }}/' -i ./.github/workflows/build.yml
sed 's/ REF_WEB:.*$/ REF_WEB: ${{ needs.check.outputs.WEB_HASH }}/' -i ./.github/workflows/build.yml
sed 's/ REF_FTL:.*$/ REF_FTL: ${{ needs.check.outputs.FTL_HASH }}/' -i ./.github/workflows/build.yml
- name: Is repository modified?
id: modified
run: |
echo "RESULT=$([ "git diff" != "" ] && echo yes || echo no)" >> $GITHUB_OUTPUT
- name: Create tag
if: ${{ steps.modified.outputs.RESULT == 'yes' }}
id: tag
run: echo "RESULT=$(bash ./scripts/tag.sh)" >> $GITHUB_OUTPUT
- name: Echo tag
run: echo ${{ steps.tag.outputs.RESULT }}
#- name: Commit and Push changes
# if: ${{ steps.tag.outputs.RESULT != '' }}
# uses: uses: stefanzweifel/git-auto-commit-action@v5
# with:
# commit_message: 'Automatic update to ${{ steps.tag.outputs.RESULT }}'
# file_pattern: ./.github/workflow/build.yml
# tagging_message: ${{ steps.tag.outputs.RESULT }}
# push_options: --dry-run