Skip to content

Commit 7393c31

Browse files
authored
chore: github CI completes when new site is up (#661)
1 parent f2c378f commit 7393c31

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

.github/scripts/wait-for-deploy.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [ "$#" -lt 2 ]; then
6+
echo "Usage: $0 <endpoint> <git-short-hash>"
7+
exit 1
8+
fi
9+
10+
ENDPOINT="$1"
11+
TARGET_HASH="$2"
12+
# If no third argument is provided, no delay is applied
13+
if [ "$#" -ge 3 ]; then
14+
MAX_DELAY="$3"
15+
fi
16+
17+
# Initial delay in seconds (60, then doubles each time)
18+
DELAY=60
19+
20+
echo "Watching $ENDPOINT for Build: staging@$TARGET_HASH ..."
21+
while true
22+
do
23+
PAGE_CONTENT="$(curl -s "$ENDPOINT")"
24+
25+
# If the page contains the line with the hash:
26+
if echo "$PAGE_CONTENT" | grep -q "Build: staging@${TARGET_HASH}"; then
27+
echo "Found Build: staging@${TARGET_HASH}!"
28+
exit 0
29+
fi
30+
31+
echo "Not found yet. Sleeping for ${DELAY} seconds..."
32+
sleep "$DELAY"
33+
34+
# Exponential backoff
35+
DELAY=$((DELAY * 2))
36+
37+
# cap the delay if a maximum delay is provided
38+
if [ -n "$MAX_DELAY" ] && [ $DELAY -gt $MAX_DELAY ]; then
39+
DELAY=$MAX_DELAY
40+
fi
41+
done

.github/workflows/deploy-to-production.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ jobs:
1818
environment: production
1919
secrets:
2020
DEPLOYMENT_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
21+
wait-for-deploy:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Wait for deployment to complete
26+
run: |
27+
./.github/scripts/wait-for-deploy.sh https://inbrowser.link ${{ inputs.tag }}

.github/workflows/deploy-to-staging.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ jobs:
1818
environment: staging
1919
secrets:
2020
DEPLOYMENT_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
21+
wait-for-deploy:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Wait for deployment to complete
26+
run: |
27+
./.github/scripts/wait-for-deploy.sh https://inbrowser.dev ${{ inputs.tag }}

0 commit comments

Comments
 (0)