-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (55 loc) · 2.54 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
name: karellen-smartmontools-next-update
on:
schedule:
- cron: "0 */6 * * *"
workflow_dispatch:
jobs:
check-update:
runs-on: ubuntu-24.04
timeout-minutes: 600
continue-on-error: false
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 60
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- 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)"
if [ -z "$MODULES_CHANGED" ]; then
echo "# No submodules changed detected - exiting!" >> $GITHUB_STEP_SUMMARY
exit 0
fi
git submodule sync --recursive
git submodule update --init --remote --recursive
git config --global user.email "[email protected]"
git config --global user.name "Karellen Supervisor"
git commit -a -m "Update $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
export DEBIAN_FRONTEND=noninteractive
PATH=~/.local/bin:$PATH
export PATH
sudo apt-get update && sudo apt-get install rpm python3-rpm -y
pip3 install --user --break-system-packages --no-input tito
tito tag --accept-auto-changelog
git push --follow-tags