фикс ранера на обновление
This commit is contained in:
1 parent
8f7ffe02a2
commit
55fd998ef2
5 files changed
+71
-17
No files matched your search
+18
-12
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
export GIT_TERMINAL_PROMPT=0
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
state_dir=/home/koden/.local/state/oktp-deploy
|
||||
@@ -11,15 +12,23 @@ test -r "$env_file" || { echo "Missing $env_file" >&2; exit 1; }
|
||||
sha=$(git rev-parse HEAD)
|
||||
image="oktp-docs:$sha"
|
||||
|
||||
is_latest() {
|
||||
local remote_sha
|
||||
remote_sha=$(git ls-remote https://sulaco.nodered.ru:5333/COD2/OKTP_SERVER.git refs/heads/main | cut -f1)
|
||||
[[ "$remote_sha" == "$sha" ]]
|
||||
check_latest_or_exit() {
|
||||
local remote_refs remote_sha
|
||||
if ! remote_refs=$(git ls-remote https://sulaco.nodered.ru:5333/COD2/OKTP_SERVER.git refs/heads/main); then
|
||||
echo 'Cannot read main from Gitea. Check job token access and network.' >&2
|
||||
exit 1
|
||||
fi
|
||||
remote_sha=$(printf '%s\n' "$remote_refs" | cut -f1)
|
||||
if [[ -z "$remote_sha" ]]; then
|
||||
echo 'Remote main branch is missing.' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$remote_sha" != "$sha" ]]; then
|
||||
echo 'A newer commit exists; keeping current site.'
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
if ! is_latest; then
|
||||
echo 'Cannot confirm this commit is latest main; skipping deployment.'
|
||||
exit 0
|
||||
fi
|
||||
check_latest_or_exit
|
||||
|
||||
docker build --label "org.opencontainers.image.revision=$sha" -t "$image" .
|
||||
|
||||
@@ -72,10 +81,7 @@ else:
|
||||
raise SystemExit("Candidate did not start")
|
||||
'
|
||||
docker rm -f "$probe" >/dev/null
|
||||
if ! is_latest; then
|
||||
echo 'A newer commit exists or Gitea is unavailable; keeping current site.'
|
||||
exit 0
|
||||
fi
|
||||
check_latest_or_exit
|
||||
|
||||
if docker container inspect oktp-docs >/dev/null 2>&1; then
|
||||
# AutoRemove containers cannot be preserved for rollback after stopping.
|
||||
|
||||
Reference in new issue
Block a user