Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/scripts/get-netlify-branch-deploy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Fetches the latest published Netlify deploy for the current branch and outputs its URL for GitHub Actions
// Fetches the latest ready Netlify deploy for the current branch and outputs its URL for GitHub Actions
import fs from "fs"

const siteId = process.env.NETLIFY_SITE_ID
Expand All @@ -13,7 +13,6 @@ if (!siteId || !branch || !token) {
type NetlifyDeploy = {
state: string
branch: string
published: boolean
deploy_ssl_url?: string
deploy_url?: string
}
Expand All @@ -31,12 +30,10 @@ type NetlifyDeploy = {
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
)
// Find the latest ready deploy for this branch
const latest = deploys.find((d) => d.state === "ready" && d.branch === branch)
if (!latest) {
console.error("No published deploy found for branch:", branch)
console.error("No ready deploy found for branch:", branch)
process.exit(1)
}
// Use GitHub Actions recommended output syntax (GITHUB_OUTPUT)
Expand Down