From a2133450cce6ef8a548bd618708fc444d0efa5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20C=C3=A9sar=C3=A9-Herriau?= Date: Wed, 22 Oct 2025 12:49:18 -0400 Subject: [PATCH] Upgrade Node to 24, add logs --- .gitignore | 12 ++++++++---- action.yml | 4 ++-- dist/index.js | 25 +++++++++++++++++-------- package-lock.json | 2 ++ src/action.js | 25 +++++++++++++++++-------- 5 files changed, 46 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index bdeae76..03bd3b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ -# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,node -# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,macos,node +# Created by https://www.toptal.com/developers/gitignore/api/node,macos,visualstudiocode,asdf +# Edit at https://www.toptal.com/developers/gitignore?templates=node,macos,visualstudiocode,asdf + +### asdf ### +/.tool-versions ### macOS ### # General @@ -76,7 +79,7 @@ bower_components build/Release # Dependency directories -/node_modules +node_modules/ jspm_packages/ # Snowpack dependency directory (https://snowpack.dev/) @@ -126,6 +129,7 @@ out # Nuxt.js build / generate output .nuxt +dist # Gatsby files .cache/ @@ -192,4 +196,4 @@ out .history .ionide -# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,node +# End of https://www.toptal.com/developers/gitignore/api/node,macos,visualstudiocode,asdf \ No newline at end of file diff --git a/action.yml b/action.yml index 6e93b55..8019f74 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: "Render Deploy Action - fork" +name: "Render Deploy Action" description: "Trigger a Render service deploy" inputs: service-id: @@ -11,5 +11,5 @@ inputs: description: "Should job wait for deployment to succeed" required: false runs: - using: "node16" + using: "node24" main: "dist/index.js" diff --git a/dist/index.js b/dist/index.js index 8f07c9f..b918e98 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8742,22 +8742,24 @@ const WAIT_FOR_SUCCESS = async function retrieveStatus(deployId) { const response = await fetch( - "https://api.render.com/v1/services/" + SERVICEID + "/deploys/" + deployId, + `https://api.render.com/v1/services/${SERVICEID}/deploys/${deployId}`, { headers: { Authorization: `Bearer ${APIKEY}` }, }, ); - const data = await response.json(); if (response.ok) { + const data = await response.json(); return data.status; } else { throw Error("Could not retrieve deploy information.") } } -async function waitForSuccess(data) { - let previousStatus = ""; +async function waitForSuccess(data, currentStatus) { + core.info(`Waiting for deploy to succeed`); + + let previousStatus = currentStatus; while (true) { await new Promise((res) => { setTimeout(res, 10000); @@ -8766,7 +8768,7 @@ async function waitForSuccess(data) { const status = await retrieveStatus(data.id); if (status !== previousStatus) { - core.info(`Deploy status: ${status}`); + core.info(`Deploy status changed: ${status}`); previousStatus = status; } @@ -8784,7 +8786,7 @@ async function waitForSuccess(data) { async function run() { const response = await fetch( - "https://api.render.com/v1/services/" + SERVICEID + "/deploys", + `https://api.render.com/v1/services/${SERVICEID}/deploys`, { method: "POST", headers: { Authorization: `Bearer ${APIKEY}` }, @@ -8805,10 +8807,17 @@ async function run() { return; } - core.info(`Deploy ${data.status} - Commit: ${data.commit.message}`); + let ref = "unknown"; + if (data.commit) { + ref = `git commit: ${data.commit.message}`; + } else if (data.image) { + ref = `image: ${data.image.ref} SHA: ${data.image.sha}`; + } + core.info(`Deploy triggered for ${ref}`); + core.info(`Status: ${data.status}`); if (WAIT_FOR_SUCCESS) { - await waitForSuccess(data); + await waitForSuccess(data, data.status); } } diff --git a/package-lock.json b/package-lock.json index 37c11b7..8a50359 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59,6 +59,7 @@ "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.5.1.tgz", "integrity": "sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==", "dev": true, + "peer": true, "dependencies": { "@octokit/auth-token": "^2.4.4", "@octokit/graphql": "^4.5.8", @@ -394,6 +395,7 @@ "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.5.1.tgz", "integrity": "sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==", "dev": true, + "peer": true, "requires": { "@octokit/auth-token": "^2.4.4", "@octokit/graphql": "^4.5.8", diff --git a/src/action.js b/src/action.js index fcbad36..68f8a00 100644 --- a/src/action.js +++ b/src/action.js @@ -8,22 +8,24 @@ const WAIT_FOR_SUCCESS = async function retrieveStatus(deployId) { const response = await fetch( - "https://api.render.com/v1/services/" + SERVICEID + "/deploys/" + deployId, + `https://api.render.com/v1/services/${SERVICEID}/deploys/${deployId}`, { headers: { Authorization: `Bearer ${APIKEY}` }, }, ); - const data = await response.json(); if (response.ok) { + const data = await response.json(); return data.status; } else { throw Error("Could not retrieve deploy information.") } } -async function waitForSuccess(data) { - let previousStatus = ""; +async function waitForSuccess(data, currentStatus) { + core.info(`Waiting for deploy to succeed`); + + let previousStatus = currentStatus; while (true) { await new Promise((res) => { setTimeout(res, 10000); @@ -32,7 +34,7 @@ async function waitForSuccess(data) { const status = await retrieveStatus(data.id); if (status !== previousStatus) { - core.info(`Deploy status: ${status}`); + core.info(`Deploy status changed: ${status}`); previousStatus = status; } @@ -50,7 +52,7 @@ async function waitForSuccess(data) { async function run() { const response = await fetch( - "https://api.render.com/v1/services/" + SERVICEID + "/deploys", + `https://api.render.com/v1/services/${SERVICEID}/deploys`, { method: "POST", headers: { Authorization: `Bearer ${APIKEY}` }, @@ -71,10 +73,17 @@ async function run() { return; } - core.info(`Deploy ${data.status} - Commit: ${data.commit.message}`); + let ref = "unknown"; + if (data.commit) { + ref = `git commit: ${data.commit.message}`; + } else if (data.image) { + ref = `image: ${data.image.ref} SHA: ${data.image.sha}`; + } + core.info(`Deploy triggered for ${ref}`); + core.info(`Status: ${data.status}`); if (WAIT_FOR_SUCCESS) { - await waitForSuccess(data); + await waitForSuccess(data, data.status); } }