From 8fb1f315bbb3c6a750abeaff84cec0b99fd11ae6 Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Thu, 2 Nov 2023 11:51:52 +0100 Subject: [PATCH] Add step to wait for launcher files to be ready (#576) Adds a small bash script and calls it in CI to block the CI from progressing until the launcher release files are uploaded. --- .github/workflows/build.yml | 4 ++++ wait_for_launcher_dl.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 wait_for_launcher_dl.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fa5f63..7dd9fd1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,10 @@ jobs: build-northstar: runs-on: ubuntu-20.04 steps: + - name: Wait for launcher release build to be ready + timeout-minutes: 30 # Only wait for 30 minutes. If we take longer, something probably broke + run: + bash wait_dl.sh - name: Download compiled launcher run: wget "https://github.com/R2Northstar/NorthstarLauncher/releases/download/${{ env.NORTHSTAR_VERSION }}/northstar-launcher.zip" diff --git a/wait_for_launcher_dl.sh b/wait_for_launcher_dl.sh new file mode 100755 index 0000000..0320595 --- /dev/null +++ b/wait_for_launcher_dl.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Check if contains command line arg +if [ -z "$1" ]; then + echo "Missing command-line argument." + exit 1 +fi + +url="https://github.com/R2Northstar/NorthstarLauncher/releases/tag/$1" +wait_time_seconds=60 + +# Loop until the response code changes +while true; do + response=$(curl --silent --output /dev/null --write-out "%{http_code}" $url) + if [ $response -ne 200 ]; then + echo "Response is not 200. Retrying in $wait_time_seconds seconds." + sleep $wait_time_seconds + else + echo "Site is accessible with response code $response." + break + fi +done + +# 10 second sleep just in case we hit some weird race condition +# where files are still being uploaded but release is done +sleep 10