ci: wait for image validate using PR head SHA

gh run list keys off the branch head commit, not the merge ref GITHUB_SHA
used in workflow_call Playwright jobs.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-10-08 03:23:09 +00:00
parent f2613a9a90
commit b5249acbd1
No known key found for this signature in database

View File

@ -67,18 +67,29 @@ jobs:
if: github.event_name == 'pull_request' || github.event_name == 'workflow_call' if: github.event_name == 'pull_request' || github.event_name == 'workflow_call'
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: | run: |
set -euo pipefail set -euo pipefail
sha="${GITHUB_SHA}" shas=("${GITHUB_SHA}")
echo "Waiting for publish-server-image on ${sha} before starting Vite…" if [[ -n "${PR_HEAD_SHA}" ]]; then
for attempt in $(seq 1 120); do shas+=("${PR_HEAD_SHA}")
fi
run_id=""
for sha in "${shas[@]}"; do
run_id="$(gh run list --repo "${GITHUB_REPOSITORY}" --commit "${sha}" \ run_id="$(gh run list --repo "${GITHUB_REPOSITORY}" --commit "${sha}" \
--workflow publish-server-image.yml --limit 1 \ --workflow publish-server-image.yml --limit 1 \
--json databaseId,status -q '.[0].databaseId // empty')" --json databaseId -q '.[0].databaseId // empty')"
if [[ -z "${run_id}" ]]; then if [[ -n "${run_id}" ]]; then
echo "No publish-server-image run for this commit; continuing." echo "Found publish-server-image run ${run_id} for commit ${sha}."
exit 0 break
fi fi
done
if [[ -z "${run_id}" ]]; then
echo "No publish-server-image run for ${shas[*]}; continuing."
exit 0
fi
echo "Waiting for publish-server-image before starting Vite…"
for attempt in $(seq 1 120); do
status="$(gh run view "${run_id}" --repo "${GITHUB_REPOSITORY}" --json status -q .status)" status="$(gh run view "${run_id}" --repo "${GITHUB_REPOSITORY}" --json status -q .status)"
if [[ "${status}" == "completed" ]]; then if [[ "${status}" == "completed" ]]; then
echo "publish-server-image run ${run_id} completed." echo "publish-server-image run ${run_id} completed."