-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (51 loc) · 2.33 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
name: karellen-manylinux-update
on:
schedule:
- cron: "0 */1 * * *"
workflow_dispatch:
jobs:
check-update:
runs-on: linux
timeout-minutes: 600
continue-on-error: false
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 60
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
- name: Check Updates
shell: bash
run: |
set -eEux
set -o pipefail
shopt -s extglob
MODULES_CHANGED=""
while read line; do
read -r SUBMODULE_SHA SUBMODULE_NAME SUBMODULE_DESCRIBE <<<"$line"
# The submodules here are not initialized so there'll be a '-' in front of the local SHA
SUBMODULE_SHA=${SUBMODULE_SHA:1}
GIT_CONFIG="$(git config -f .gitmodules -l | grep 'submodule.'$SUBMODULE_NAME.)"
SUBMODULE_URL="$(echo "$GIT_CONFIG" | grep 'submodule.'$SUBMODULE_NAME'.url=' | sed 's/submodule\.'$SUBMODULE_NAME'\.url=//')"
SUBMODULE_BRANCH="$(echo "$GIT_CONFIG" | grep 'submodule.'$SUBMODULE_NAME'.branch=' | sed 's/submodule\.'$SUBMODULE_NAME'\.branch=//')"
read -r REMOTE_SHA REMOTE_REF <<<"$(git ls-remote $SUBMODULE_URL | grep 'refs/heads/'$SUBMODULE_BRANCH)"
if [ "$SUBMODULE_SHA" != "$REMOTE_SHA" ]; then
echo "## Submodule $SUBMODULE_NAME @ $SUBMODULE_URL/tree/$SUBMODULE_BRANCH local $SUBMODULE_SHA vs remote $REMOTE_SHA" >> $GITHUB_STEP_SUMMARY
MODULES_CHANGED="1"
else
echo "## Submodule $SUBMODULE_NAME @ $SUBMODULE_URL/tree/$SUBMODULE_BRANCH local $SUBMODULE_SHA unchanged" >> $GITHUB_STEP_SUMMARY
fi
done <<< "$(git submodule status)"
git submodule sync --recursive
git submodule update --init --remote --recursive
./patch_build_yml.sh
if [ -z "$MODULES_CHANGED" -a -z "$(git status --porcelain)" ]; then
echo "# No submodule or other changed detected - exiting!" >> $GITHUB_STEP_SUMMARY
exit 0
fi
git config --global user.email "supervisor@karellen.co"
git config --global user.name "Karellen Supervisor"
git add \*
git commit -a -m "Update $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
git push --follow-tags