@@ -2,12 +2,76 @@ name: Build AltServer
2
2
3
3
on :
4
4
push :
5
+ workflow_dispatch :
6
+ inputs :
7
+ sync_upstream :
8
+ required : false
9
+ default : false
10
+ debug_enabled :
11
+ description : ' Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
12
+ required : false
13
+ default : false
14
+ repository_dispatch :
15
+
16
+ schedule :
17
+ - cron : " 0 */4 * * *" # min hour day week year
18
+
5
19
6
20
env :
7
21
REGISTRY : ghcr.io
8
22
9
23
jobs :
24
+ check :
25
+ runs-on : ubuntu-latest
26
+ name : " Check Upstream Updates"
27
+ steps :
28
+ - name : Checkout
29
+ uses : actions/checkout@v2
30
+ with :
31
+ fetch-depth : 0
32
+ submodules : recursive
33
+
34
+ - name : Check If Need Checking
35
+ id : needCheck
36
+ if : ${{ github.event_name == 'schedule' || ( github.event_name == 'workflow_dispatch' && github.event.inputs.sync_upstream ) }}
37
+ run : |
38
+ echo "needCheck=1" >> $GITHUB_ENV
39
+
40
+ - name : Check Upstream Version
41
+ id : check
42
+ run : |
43
+ if [[ "$needCheck" == 1 ]]; then
44
+ echo "Checking changes in upstream_repo..."
45
+
46
+ current_upstream=$(git ls-tree HEAD upstream_repo | awk '{ print $3 }')
47
+ echo "Current Upstream Commit: $current_upstream"
48
+
49
+ git submodule update --remote -- upstream_repo
50
+ new_upstream=$( cd upstream_repo; git show -s --format=%H )
51
+ echo "New Upstream Commit: $new_upstream"
52
+
53
+ git reset --hard
54
+ git submodule update --init
55
+ if [[ "$current_upstream" != "$new_upstream" ]]; then
56
+ echo "Upstream got new commits, go updating!"
57
+ echo "::set-output name=updated::1"
58
+ else
59
+ echo "Upstream no change~"
60
+ echo "::set-output name=updated::0"
61
+ fi
62
+ else
63
+ echo "Needn't to check changes, directly return~"
64
+ echo "::set-output name=updated::0"
65
+ fi
66
+
67
+ - uses : gautamkrishnar/keepalive-workflow@master
68
+ with :
69
+ commit_message : " [proj] keepalive-workflow auto commit"
70
+ outputs :
71
+ updated : ${{ steps.check.outputs.updated }}
72
+
10
73
build :
74
+ needs : [check]
11
75
strategy :
12
76
matrix :
13
77
builder : [ghcr.io/nyamisty/altserver_builder_alpine_armv7, ghcr.io/nyamisty/altserver_builder_alpine_aarch64, ghcr.io/nyamisty/altserver_builder_alpine_amd64, ghcr.io/nyamisty/altserver_builder_alpine_i386]
18
82
with :
19
83
fetch-depth : 0
20
84
submodules : recursive
85
+ - name : Do Submodule Update
86
+ if : ${{ needs.check.outputs.updated == '1' }}
87
+ run :
88
+ git submodule update --remote -- upstream_repo
21
89
-
22
90
name : Set up QEMU
23
91
uses : docker/setup-qemu-action@v1
44
112
45
113
release :
46
114
runs-on : ubuntu-latest
115
+ if : ${{ startsWith(github.ref, 'refs/tags/') }}
47
116
needs : [build]
48
117
name : " release"
49
118
steps :
@@ -63,9 +132,30 @@ jobs:
63
132
if [ "$(ls -A build_release)" ]; then exit 0; else exit 1; fi
64
133
- name : Release
65
134
uses : softprops/action-gh-release@v1
66
- if : ${{ startsWith(github.ref, 'refs/tags/') }}
67
135
with :
68
136
files : build_release/*
69
137
env :
70
138
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
71
-
139
+
140
+ update_submodule :
141
+ runs-on : ubuntu-latest
142
+ needs : [check, build]
143
+ if : ${{ needs.check.outputs.updated == '1' }}
144
+ steps :
145
+ - name : Checkout
146
+ uses : actions/checkout@v2
147
+ with :
148
+ fetch-depth : 0
149
+ submodules : recursive
150
+ - name : Commit Submodule Update
151
+ run : |
152
+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
153
+ git config --local user.name "github-actions[bot]"
154
+ git submodule update --remote -- upstream_repo
155
+ git commit -m "[server] Sync Upstream Repo commit" upstream_repo
156
+ - name : Push changes
157
+ uses : ad-m/github-push-action@master
158
+ with :
159
+ github_token : ${{ secrets.GITHUB_TOKEN }}
160
+ branch : ${{ github.ref }}
161
+
0 commit comments