Skip to content

ci: replace fixed 120s sleep with preview URL polling in PR workflows#43

Merged
Primajin merged 2 commits into
mainfrom
copilot/update-preview-workflows
Jul 11, 2026
Merged

ci: replace fixed 120s sleep with preview URL polling in PR workflows#43
Primajin merged 2 commits into
mainfrom
copilot/update-preview-workflows

Conversation

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

The console and screenshots PR preview workflows used a hard sleep 120s to wait for the GitHub Pages preview to become available — too short sometimes, wasteful always. This replaces it with a curl polling loop that exits as soon as the preview responds 2xx (up to 180s timeout).

Changes

Both .github/workflows/console.yml and .github/workflows/screenshots.yml:

  • Added job-level PREVIEW_URL env var — single source of truth for the preview URL, reused in all downstream steps
  • Replaced Sleep for 120 seconds step with a bash polling loop: checks every 5s, succeeds on any 2xx, exits 1 after 180s timeout
  • Removed PR_NUMBER step-level env in screenshots.yml — now uses ${{ env.PREVIEW_URL }} directly
env:
  PREVIEW_URL: https://primajin.github.io/Gyros/pr-preview/pr-${{ github.event.number }}/

- name: Wait for preview URL to be available
  if: steps.wait-for-build.outputs.conclusion == 'success'
  shell: bash
  run: |
    timeout=180; elapsed=0
    until [ "$elapsed" -ge "$timeout" ]; do
      status=$(curl --silent --output /dev/null --write-out "%{http_code}" "${PREVIEW_URL}" || true)
      if [[ "$status" =~ ^2 ]]; then echo "Preview is live (HTTP ${status})"; exit 0; fi
      echo "HTTP ${status} – retrying in 5 s (${elapsed}/${timeout}s elapsed)"
      sleep 5; elapsed=$((elapsed + 5))
    done
    echo "Timed out waiting for preview after ${timeout}s"; exit 1

Copilot AI requested review from Copilot and removed request for Copilot July 11, 2026 09:04
Copilot AI requested review from Copilot and removed request for Copilot July 11, 2026 09:05
Copilot AI changed the title [WIP] Update pull request preview workflows with polling strategy Replace fixed 120s sleep with preview URL polling in PR workflows Jul 11, 2026
Copilot AI requested a review from Primajin July 11, 2026 09:05
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://Primajin.github.io/Gyros/pr-preview/pr-43/

Built to branch gh-pages at 2026-07-11 09:09 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

Copy link
Copy Markdown
Contributor

@Primajin Primajin changed the title Replace fixed 120s sleep with preview URL polling in PR workflows ci: replace fixed 120s sleep with preview URL polling in PR workflows Jul 11, 2026
@Primajin
Primajin marked this pull request as ready for review July 11, 2026 09:10
Copilot AI review requested due to automatic review settings July 11, 2026 09:10
@github-actions

Copy link
Copy Markdown
Contributor

Console Logs

✅ No logs were captured

@Primajin
Primajin merged commit 0e66207 into main Jul 11, 2026
19 of 22 checks passed
@Primajin
Primajin deleted the copilot/update-preview-workflows branch July 11, 2026 09:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the reliability and efficiency of PR preview-dependent workflows by replacing a fixed 120s wait with a polling mechanism that proceeds as soon as the GitHub Pages preview becomes available.

Changes:

  • Add a job-level PREVIEW_URL env var as a single source of truth for the PR preview URL.
  • Replace the fixed sleep 120s step with a curl-based polling loop (up to 180s) that succeeds on HTTP 2xx.
  • Update downstream steps to consume ${{ env.PREVIEW_URL }} (removing the step-level PR_NUMBER env in screenshots.yml).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/screenshots.yml Adds PREVIEW_URL and replaces fixed sleep with polling before running screenshot capture against the preview.
.github/workflows/console.yml Adds PREVIEW_URL, replaces fixed sleep with polling, and reuses the env var for the console log action URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

timeout=180
elapsed=0
until [ "$elapsed" -ge "$timeout" ]; do
status=$(curl --silent --output /dev/null --write-out "%{http_code}" "${PREVIEW_URL}" || true)
timeout=180
elapsed=0
until [ "$elapsed" -ge "$timeout" ]; do
status=$(curl --silent --output /dev/null --write-out "%{http_code}" "${PREVIEW_URL}" || true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants