-
Notifications
You must be signed in to change notification settings - Fork 0
/
script-redo-actions.sh
executable file
·238 lines (201 loc) · 7.58 KB
/
script-redo-actions.sh
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/bin/bash
#
# Checkout and update the branch on all repos
set -e
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
BRANCH_NAME=update-$DEFAULT_BRANCH-php-testing-versions
echo "Fetch $DEFAULT_BRANCH"
echo "======================"
git fetch origin $DEFAULT_BRANCH
echo "Checkout $DEFAULT_BRANCH"
echo "======================"
git checkout $DEFAULT_BRANCH
echo "Reset $DEFAULT_BRANCH"
echo "======================"
git reset --hard origin/$DEFAULT_BRANCH
set +e
echo ""
echo "Delete existing branch"
echo "======================"
git branch -D $BRANCH_NAME
set -e
echo ""
echo "Checkout branch"
echo "======================"
git checkout -b $BRANCH_NAME
CHANGED="0"
for FILE in appstore-build-publish.yml \
command-compile.yml \
command-rebase.yml \
dependabot-approve-merge.yml \
fixup.yml \
lint.yml \
lint-eslint.yml \
lint-info-xml.yml \
lint-php.yml \
lint-php-cs.yml \
lint-stylelint.yml \
node.yml \
npm-publish.yml \
phpunit.yml \
phpunit-mysql.yml \
phpunit-oci.yml \
phpunit-pgsql.yml \
phpunit-sqlite.yml \
phpunit-summary-when-unrelated.yml \
static-analysis.yml \
psalm.yml \
psalm-matrix.yml \
update-christophwurst-nextcloud.yml \
update-nextcloud-ocp.yml \
update-nextcloud-ocp-matrix.yml
do
echo ""
echo "Loop: $FILE"
echo "======================"
if [[ "$FILE" = "static-analysis.yml" ]]; then
if [ -f '.github/workflows/static-analysis.yml' ]; then
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/psalm-matrix.yml .github/workflows/psalm-matrix.yml
mv .github/workflows/static-analysis.yml .github/workflows/psalm-matrix.yml
git add .github/workflows/
fi
continue
fi
if [[ "$FILE" = "update-christophwurst-nextcloud.yml" ]]; then
if [ -f '.github/workflows/update-christophwurst-nextcloud.yml' ]; then
gh repo set-default
gh issue create -t "Replace christophwurst/nextcloud package with nextcloud/ocp" -b "See the update-nextcloud-ocp.yml or update-nextcloud-ocp-matrix.yml (for multi version support) in https://github.com/nextcloud/.github/tree/master/workflow-templates"
fi
continue
fi
if [[ "$FILE" = "lint.yml" ]]; then
if [ -f '.github/workflows/lint.yml' ]; then
gh repo set-default
gh issue create -t "Replace lint.yml with split workflows" -b "See the lint-*.yml files in https://github.com/nextcloud/.github/tree/master/workflow-templates"
fi
continue
fi
if [[ "$FILE" = "phpunit.yml" ]]; then
if [ -f '.github/workflows/phpunit.yml' ]; then
gh repo set-default
gh issue create -t "Replace phpunit.yml with split workflows" -b "See the phpunit-*.yml files in https://github.com/nextcloud/.github/tree/master/workflow-templates"
fi
continue
fi
if [ -f ".github/workflows/$FILE" ]; then
echo ""
echo "Copy workflow-templates/$FILE"
echo "======================"
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/$FILE .github/workflows/$FILE
if [[ "$FILE" = "node.yml" ]]; then
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/node-when-unrelated.yml .github/workflows/node-when-unrelated.yml
git add .github/workflows/node-when-unrelated.yml
fi
if [[ "$FILE" = "lint-eslint.yml" ]]; then
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/lint-eslint-when-unrelated.yml .github/workflows/lint-eslint-when-unrelated.yml
git add .github/workflows/lint-eslint-when-unrelated.yml
fi
if [[ "$FILE" = "phpunit-mysql.yml" ]]; then
if [ ! -f '.github/workflows/phpunit-summary-when-unrelated.yml' ]; then
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/phpunit-summary-when-unrelated.yml .github/workflows/phpunit-summary-when-unrelated.yml
git add .github/workflows/phpunit-summary-when-unrelated.yml
fi
fi
if [[ "$FILE" = "phpunit-oci.yml" ]]; then
if [ ! -f '.github/workflows/phpunit-summary-when-unrelated.yml' ]; then
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/phpunit-summary-when-unrelated.yml .github/workflows/phpunit-summary-when-unrelated.yml
git add .github/workflows/phpunit-summary-when-unrelated.yml
fi
fi
if [[ "$FILE" = "phpunit-pgsql.yml" ]]; then
if [ ! -f '.github/workflows/phpunit-summary-when-unrelated.yml' ]; then
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/phpunit-summary-when-unrelated.yml .github/workflows/phpunit-summary-when-unrelated.yml
git add .github/workflows/phpunit-summary-when-unrelated.yml
fi
fi
if [[ "$FILE" = "phpunit-sqlite.yml" ]]; then
if [ ! -f '.github/workflows/phpunit-summary-when-unrelated.yml' ]; then
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/phpunit-summary-when-unrelated.yml .github/workflows/phpunit-summary-when-unrelated.yml
git add .github/workflows/phpunit-summary-when-unrelated.yml
fi
if [ ! -f '.github/workflows/phpunit-mysql.yml' ]; then
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/phpunit-sqlite-all-versions.yml .github/workflows/phpunit-sqlite.yml
fi
fi
echo ""
echo "Diff .github/workflows/$FILE"
echo "======================"
git --no-pager diff .github/workflows/$FILE
echo ""
echo "Update .github/workflows/$FILE"
echo "======================"
gedit .github/workflows/$FILE
echo ""
echo "Add file to git status"
echo "======================"
git add .github/workflows/$FILE
CHANGED="1"
fi
done
FILE="composer.json"
if [ -f $FILE ]; then
echo "COMPOSER.JSON"
echo "COMPOSER.JSON"
echo "COMPOSER.JSON"
echo "COMPOSER.JSON"
echo "COMPOSER.JSON"
echo "COMPOSER.JSON"
echo "COMPOSER.JSON"
echo "COMPOSER.JSON"
echo "COMPOSER.JSON"
if [ -f '.github/workflows/phpunit-summary-when-unrelated.yml' ]; then
git diff --cached .github/workflows/phpunit-sqlite.yml | grep '^-' | grep phpunit
fi
echo ""
echo "Update $FILE"
echo "======================"
gedit $FILE
composer update php
echo ""
echo "Add file to git status"
echo "======================"
git add $FILE
git add composer.lock
CHANGED="1"
elif [ -f '.github/workflows/phpunit-summary-when-unrelated.yml' ]; then
cp /home/nickv/Nextcloud/26/server/apps-action-templates/workflow-templates/dummycomposer.json composer.json
echo ""
echo "Add file to git status"
echo "======================"
git add $FILE
CHANGED="1"
fi
FILE=".drone.yml"
if [ -f '.drone.yml' ]; then
echo ""
echo "Update $FILE"
echo "======================"
gedit $FILE
echo ""
echo "Add file to git status"
echo "======================"
git add $FILE
CHANGED="1"
fi
if [[ "$CHANGED" = "0" ]]; then
echo "No testing"
exit 1
fi
echo ""
echo "Commit branch"
echo "======================"
git commit -m "chore(CI): Update $DEFAULT_BRANCH php testing versions and workflow templates
Signed-off-by: Joas Schilling <[email protected]>"
echo ""
echo "Push branch"
echo "======================"
git push origin $BRANCH_NAME
echo ""
echo "Create PR"
echo "======================"
gh pr create --base $DEFAULT_BRANCH --fill >> ../../pr-list.txt