From 06a50d36fd0ca2ed19c3646b3a2387b02de33c4a Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Sat, 27 Sep 2025 09:01:49 -0700 Subject: [PATCH 1/3] feat: add script fetching latest netlify branch deploy --- src/scripts/get-netlify-branch-deploy.ts | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/scripts/get-netlify-branch-deploy.ts diff --git a/src/scripts/get-netlify-branch-deploy.ts b/src/scripts/get-netlify-branch-deploy.ts new file mode 100644 index 00000000000..ed740f1c1f7 --- /dev/null +++ b/src/scripts/get-netlify-branch-deploy.ts @@ -0,0 +1,53 @@ +// Fetches the latest published Netlify deploy for the current branch and outputs its URL for GitHub Actions + +import fs from "fs" + +import fetch from "node-fetch" + +const siteId = process.env.NETLIFY_SITE_ID +const branch = process.env.GITHUB_REF_NAME +const token = process.env.NETLIFY_TOKEN + +if (!siteId || !branch || !token) { + console.error("Missing NETLIFY_SITE_ID, GITHUB_REF_NAME, or NETLIFY_TOKEN") + process.exit(1) +} + +type NetlifyDeploy = { + state: string + branch: string + published: boolean + deploy_ssl_url?: string + deploy_url?: string +} +;(async () => { + const url = `https://api.netlify.com/api/v1/sites/${siteId}/deploys?branch=${branch}` + const res = await fetch(url, { + headers: { Authorization: `Bearer ${token}` }, + }) + if (!res.ok) { + console.error( + "Failed to fetch Netlify deploys:", + res.status, + await res.text() + ) + process.exit(1) + } + const deploys: NetlifyDeploy[] = await res.json() + // Find the latest published deploy for this branch + const latest = deploys.find( + (d) => d.state === "ready" && d.branch === branch && d.published + ) + if (!latest) { + console.error("No published deploy found for branch:", branch) + process.exit(1) + } + // Use GitHub Actions recommended output syntax (GITHUB_OUTPUT) + const output = `url=${latest.deploy_ssl_url || latest.deploy_url}` + if (process.env.GITHUB_OUTPUT) { + fs.appendFileSync(process.env.GITHUB_OUTPUT, output + "\n") + } else { + // Fallback for local/dev + console.log(output) + } +})() From 8fb2d384644a5beaccdec0fe5a2b4f4c99300cc0 Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Sat, 27 Sep 2025 09:02:54 -0700 Subject: [PATCH 2/3] fix: use latest branch deploy; rm awaiting new build --- .github/workflows/playwright.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index b38a464aad0..67e04c153d5 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -9,14 +9,17 @@ jobs: steps: - uses: actions/checkout@v5 - - name: Wait for Netlify Deploy + - name: Get Netlify Deploy URL for branch id: netlify_deploy - uses: pettinarip/wait-for-netlify-action@v1.0.2 - with: - site_id: "e8f2e766-888b-4954-8500-1b647d84db99" - max_timeout: 3600 + if: | + github.ref_name == 'dev' || github.ref_name == 'staging' || github.ref_name == 'master' + run: | + npm install node-fetch@2 + npx ts-node -O '{ "module": "commonjs" }' src/scripts/get-netlify-branch-deploy.ts env: + NETLIFY_SITE_ID: "e8f2e766-888b-4954-8500-1b647d84db99" NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }} + GITHUB_REF_NAME: ${{ github.ref_name }} - uses: actions/setup-node@v4 with: From b735aec611df7f1b0047cce7da16ba1a0116b8bd Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Mon, 29 Sep 2025 10:11:06 -0700 Subject: [PATCH 3/3] fix: rm node-fetch --- .github/workflows/playwright.yml | 1 - src/scripts/get-netlify-branch-deploy.ts | 3 --- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 67e04c153d5..e6b8b6d83dc 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -14,7 +14,6 @@ jobs: if: | github.ref_name == 'dev' || github.ref_name == 'staging' || github.ref_name == 'master' run: | - npm install node-fetch@2 npx ts-node -O '{ "module": "commonjs" }' src/scripts/get-netlify-branch-deploy.ts env: NETLIFY_SITE_ID: "e8f2e766-888b-4954-8500-1b647d84db99" diff --git a/src/scripts/get-netlify-branch-deploy.ts b/src/scripts/get-netlify-branch-deploy.ts index ed740f1c1f7..8533e2c4bd6 100644 --- a/src/scripts/get-netlify-branch-deploy.ts +++ b/src/scripts/get-netlify-branch-deploy.ts @@ -1,9 +1,6 @@ // Fetches the latest published Netlify deploy for the current branch and outputs its URL for GitHub Actions - import fs from "fs" -import fetch from "node-fetch" - const siteId = process.env.NETLIFY_SITE_ID const branch = process.env.GITHUB_REF_NAME const token = process.env.NETLIFY_TOKEN