-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
513 changed files
with
24,812 additions
and
4,633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
body: | ||
- attributes: | ||
label: Body | ||
value: | | ||
Body of the technical discussion... | ||
id: body | ||
type: textarea | ||
- attributes: | ||
label: Additional Info | ||
value: | | ||
Any additional info... | ||
id: additional | ||
type: textarea | ||
- attributes: | ||
label: Before you submit your discussion, please confirm the following. If any of these required steps are not taken, we may not be able to review your RFC. Help us to help you! | ||
options: | ||
- label: I have [read the discussions guidelines](https://typescript-eslint.io/contributing/discussions) and per those guidelines, this fits a discussion category, _not_ a help request or standard issue. | ||
required: true | ||
- label: I have [searched for related discussions](https://github.com/typescript-eslint/typescript-eslint/discussions) and [searched for related issues](https://github.com/typescript-eslint/typescript-eslint/issues) and found none that match my proposal. | ||
required: true | ||
- label: I have [read the FAQ](https://typescript-eslint.io/linting/troubleshooting) and my problem is not listed. | ||
required: true | ||
id: required-checks | ||
type: checkboxes | ||
title: Your Title Here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Wait for the Netlify deployment for the current commit to be ready | ||
description: Wait for the Netlify deployment for the current commit to be ready | ||
|
||
inputs: | ||
netlify_token: | ||
description: The value of secrets.NETLIFY_TOKEN | ||
required: true | ||
max_timeout: | ||
description: The maximum length of time to keep retrying the Netlify api | ||
retry_interval: | ||
description: How long to wait between retries of the Netlify api | ||
|
||
runs: | ||
using: node16 | ||
main: index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
|
||
const NETLIFY_SITE_ID = '128d21c7-b2fe-45ad-b141-9878fcf5de3a'; // https://app.netlify.com/sites/typescript-eslint/overview | ||
const NETLIFY_TOKEN = core.getInput('netlify_token', { required: true }); | ||
const MAX_TIMEOUT = core.getInput('max_timeout') || 300000; // 5 minutes | ||
const RETRY_INTERVAL = core.getInput('retry_interval') || 5000; // 5 seconds | ||
|
||
const COMMIT_SHA = | ||
github.context.eventName === 'pull_request' | ||
? github.context.payload.pull_request.head.sha | ||
: github.context.sha; | ||
const BRANCH = | ||
github.context.eventName === 'pull_request' | ||
? github.context.payload.pull_request.head.ref | ||
: github.context.ref_name; | ||
|
||
if (!COMMIT_SHA || !BRANCH) { | ||
core.setFailed( | ||
`Could not determine the full commit SHA and branch from the GitHub context: ${JSON.stringify( | ||
github.context, | ||
null, | ||
2, | ||
)}`, | ||
); | ||
} | ||
|
||
async function run() { | ||
const { NetlifyAPI } = await import('netlify'); // ESM only, cannot be used with `require` | ||
const client = new NetlifyAPI(NETLIFY_TOKEN); | ||
|
||
async function getReadyDeploymentForCommitRef() { | ||
console.log( | ||
`Checking if deployment for commit "${COMMIT_SHA}" on branch "${BRANCH}" has state "ready"...`, | ||
); | ||
const deployments = await client.listSiteDeploys({ | ||
site_id: NETLIFY_SITE_ID, | ||
branch: BRANCH, | ||
}); | ||
console.log( | ||
`Found ${deployments.length} deployments for this branch "${BRANCH}"`, | ||
); | ||
const deploymentForCommit = deployments.find( | ||
deployment => deployment.commit_ref === COMMIT_SHA, | ||
); | ||
if (!deploymentForCommit) { | ||
console.log( | ||
`No deployment found yet for commit "${COMMIT_SHA}" on branch "${BRANCH}"`, | ||
); | ||
return null; | ||
} | ||
if (deploymentForCommit.state !== 'ready') { | ||
console.log( | ||
`Resolve deployment for commit "${COMMIT_SHA}" on branch "${BRANCH}", but it is not ready yet. State: ${deploymentForCommit.state}`, | ||
); | ||
return null; | ||
} | ||
return deploymentForCommit; | ||
} | ||
|
||
async function waitUntilReadyDeployment() { | ||
const maxTimeout = new Promise((_, reject) => { | ||
const id = setTimeout(() => { | ||
clearTimeout(id); | ||
reject( | ||
new Error( | ||
`Error: Timed out in ${MAX_TIMEOUT}ms, based on the configured MAX_TIMEOUT.`, | ||
), | ||
); | ||
}, MAX_TIMEOUT); | ||
}); | ||
|
||
const isReady = new Promise(async (resolve, reject) => { | ||
const checkReady = async () => { | ||
try { | ||
const readyDeployment = await getReadyDeploymentForCommitRef(); | ||
if (readyDeployment) { | ||
return resolve({ readyDeployment }); | ||
} | ||
console.log( | ||
`Deployment is not ready yet. Retrying in ${RETRY_INTERVAL}ms based on the configured RETRY_INTERVAL...`, | ||
); | ||
setTimeout(checkReady, RETRY_INTERVAL); | ||
} catch (err) { | ||
return reject(err); | ||
} | ||
}; | ||
checkReady(); | ||
}); | ||
|
||
return Promise.race([isReady, maxTimeout]); | ||
} | ||
|
||
waitUntilReadyDeployment() | ||
.then(({ readyDeployment }) => { | ||
console.log( | ||
`Resolved "ready" deployment with ID: ${readyDeployment.id}, URL: ${readyDeployment.deploy_ssl_url}`, | ||
); | ||
core.setOutput('deploy_id', readyDeployment.id); | ||
core.setOutput('url', readyDeployment.deploy_ssl_url); | ||
process.exit(0); | ||
}) | ||
.catch(error => { | ||
core.setFailed(error.message); | ||
}); | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.