From f5949cc08e937bc4ccdc7228f82c01dba3930d85 Mon Sep 17 00:00:00 2001 From: rjshrjndrn Date: Fri, 20 Sep 2024 14:17:35 +0200 Subject: [PATCH] chore(helm): check github availability before clone Signed-off-by: rjshrjndrn --- .../helmcharts/openreplay/templates/job.yaml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/helmcharts/openreplay/templates/job.yaml b/scripts/helmcharts/openreplay/templates/job.yaml index c90ab8261..f5f5a259f 100644 --- a/scripts/helmcharts/openreplay/templates/job.yaml +++ b/scripts/helmcharts/openreplay/templates/job.yaml @@ -74,7 +74,23 @@ spec: - | set -x mkdir -p /opt/openreplay/openreplay && cd /opt/openreplay/openreplay - git clone {{ .Values.global.dbMigrationUpstreamRepoURL | default "https://github.com/openreplay/openreplay" }} . + + # Function to check if GitHub is available + check_github() { + for i in {1..10}; do + if ping -c 1 github.com &> /dev/null; then + echo "GitHub is available." + git clone {{ .Values.global.dbMigrationUpstreamRepoURL | default "https://github.com/openreplay/openreplay" }} . + break + else + echo "GitHub is not available. Retrying in 3 seconds..." + sleep 3 + fi + done + } + + check_github + ls /opt/openreplay/openreplay git checkout {{ default .Chart.AppVersion .Values.dbMigrationUpstreamBranch }} || exit 10 git log -1