Skip to content

Commit

Permalink
🙏
Browse files Browse the repository at this point in the history
  • Loading branch information
quantizor committed Jul 17, 2020
1 parent 13731b7 commit 3cbac95
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Basic Usage
```yaml
steps:
- name: Wait for Netlify Deploy
uses: probablyup/wait-for-netlify-action@3
uses: probablyup/wait-for-netlify-action@3.0.1
id: waitForNetlifyDeploy
with:
site_id: 'YOUR_SITE_ID' # See Settings > Site Details > General in the Netlify UI
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
run: |
npm run build
- name: Waiting for 200 from Netlify
uses: probablyup/wait-for-netlify-action@3
uses: probablyup/wait-for-netlify-action@3.0.1
id: waitForNetlifyDeploy
with:
site_id: 'YOUR_SITE_ID' # See Settings > Site Details > General in the Netlify UI
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ branding:
icon: "clock"
color: "blue"
inputs:
site_name:
description: "The Netlify site name to test against"
site_id:
description: "The Netlify site id to test against"
required: true
max_timeout:
description: "The max time to run the action"
description: "The max time to wait after the deployment is ready for a valid HTTP status code"
required: false
outputs:
url:
Expand Down
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ function getNetlifyUrl(url) {
});
}

const waitForReadiness = async (url, MAX_TIMEOUT) => {
const waitForReadiness = (url, MAX_TIMEOUT) => {
return new Promise((resolve, reject) => {
let elapsedTimeSeconds = 0;

const handle = setInterval(() => {
const handle = setInterval(async () => {
elapsedTimeSeconds += 30;

if (elapsedTimeSeconds >= MAX_TIMEOUT) {
Expand All @@ -27,14 +27,13 @@ const waitForReadiness = async (url, MAX_TIMEOUT) => {
if (deploy.state === 'ready' || deploy.state === 'current') {
clearInterval(handle);
resolve();
}
else if (deploy.state === 'building') console.log('Deployment not yet ready, waiting 30 seconds...');
} else if (deploy.state === 'building') console.log('Deployment not yet ready, waiting 30 seconds...');
else {
clearInterval(handle);
reject(`Netlify deployment not available with state: ${deploy.state}.`);
}
}, 30000)
})
}, 30000);
});
};

const waitForUrl = async (url, MAX_TIMEOUT) => {
Expand Down Expand Up @@ -85,7 +84,10 @@ const run = async () => {
core.setOutput('url', url);
core.setOutput('deploy_id', commitDeployment.id);

await waitForReadiness(`https://api.netlify.com/api/v1/sites/${siteId}/deploys/${commitDeployment.id}`, MAX_WAIT_TIMEOUT)
await waitForReadiness(
`https://api.netlify.com/api/v1/sites/${siteId}/deploys/${commitDeployment.id}`,
MAX_WAIT_TIMEOUT
);

console.log(`Waiting for a 200 from: ${url}`);
await waitForUrl(url, MAX_READY_TIMEOUT);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wait-for-netlify-action",
"version": "3.0.0",
"version": "3.0.1",
"description": "A GitHub action that waits for a Netlify deployment preview for the current commit being built",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 3cbac95

Please sign in to comment.