@@ -38,23 +38,47 @@ jobs:
3838
3939 - uses : ./.github/actions/node-npm-setup
4040
41- - name : Wait for production to match build number
41+ - name : Wait for production to match build commit SHA
4242 if : github.event_name != 'workflow_dispatch'
43+ # A single /_build match only proves *one* Moda instance is serving the
44+ # new build; others can still be mid-rollout. If we purge then, Fastly's
45+ # soft purge serves stale-while-revalidate and may revalidate against a
46+ # lagging instance, re-caching old content as fresh for a full TTL. So we
47+ # require several consecutive matches to confirm the rollout has settled
48+ # across instances before purging.
4349 run : |
4450 needs=$(git rev-parse HEAD)
4551 start_time=$(date +%s)
4652 timeout_seconds=1200
47- while [[ $needs != $(curl -s --fail --retry-connrefused --retry 5 https://docs.github.com/_build) ]]
53+ required_matches=5
54+ interval_seconds=10
55+ consecutive=0
56+ while [[ $consecutive -lt $required_matches ]]
4857 do
4958 if [[ $(($(date +%s) - $start_time)) -gt $timeout_seconds ]]
5059 then
51- echo "Production did not match the build number within $timeout_seconds seconds"
60+ echo "Production did not reach $required_matches consecutive build matches within $timeout_seconds seconds"
5261 exit 1
5362 fi
54- echo "Production is not up to date with the build commit"
55- sleep 10
63+ if [[ $needs == $(curl -s --fail --retry-connrefused --retry 5 https://docs.github.com/_build) ]]
64+ then
65+ consecutive=$((consecutive + 1))
66+ echo "Production matches the build commit ($consecutive/$required_matches)"
67+ else
68+ if [[ $consecutive -gt 0 ]]
69+ then
70+ echo "Production stopped matching the build commit; resetting consecutive count"
71+ else
72+ echo "Production is not up to date with the build commit"
73+ fi
74+ consecutive=0
75+ fi
76+ if [[ $consecutive -lt $required_matches ]]
77+ then
78+ sleep $interval_seconds
79+ fi
5680 done
57- echo "Production is up to date with the build commit"
81+ echo "Production is up to date with the build commit ($required_matches consecutive matches) "
5882
5983 - name : Purge Fastly edge cache per language
6084 env :
0 commit comments