-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtrigger.sh
More file actions
executable file
·66 lines (56 loc) · 1.84 KB
/
Copy pathtrigger.sh
File metadata and controls
executable file
·66 lines (56 loc) · 1.84 KB
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
#!/bin/bash
# Copyright AppsCode Inc. and Contributors
#
# Licensed under the AppsCode Community License 1.0.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://github.com/appscode/licenses/raw/1.0.0/AppsCode-Community-1.0.0.md
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eou pipefail
SCRIPT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}"))
SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}")
PR_BRANCH=autofixer-$(date +%s)
COMMIT_MSG="Update charts"
skip_trigger() {
while IFS=$': \r\t' read -r -u9 marker v; do
if [ "$marker" = "/skip-trigger" ]; then
return 0
fi
done 9< <(git show -s --format=%b)
return 1
}
skip_trigger && {
echo "Skipped recursive trigger."
exit 0
}
repo_uptodate() {
ignorefiles=(stable/index.yaml)
# https://remarkablemark.org/blog/2017/10/12/check-git-dirty/
changed=($(git status --porcelain | awk '{print $2}'))
changed+=("${ignorefiles[@]}")
# https://stackoverflow.com/a/28161520
diff=($(echo ${changed[@]} ${ignorefiles[@]} | tr ' ' '\n' | sort | uniq -u))
return ${#diff[@]}
}
echo "Update chart repo"
make gen fmt
uibuilder-tools check --wizard-dir=./charts --fmt-only
./hack/scripts/update-local-repo.sh
if repo_uptodate; then
echo "Repository is up-to-date."
exit 0
fi
git checkout -b $PR_BRANCH
git add --all
git commit -a -s -m "$COMMIT_MSG" -m "/skip-trigger"
git push -u origin HEAD
gh pr create \
--label automerge \
--title "$COMMIT_MSG" \
--body "$(git show -s --format=%b)"