diff --git a/scripts/publish-website.sh b/scripts/publish-website.sh index a6b00e205e..5bac5dd67f 100755 --- a/scripts/publish-website.sh +++ b/scripts/publish-website.sh @@ -8,6 +8,7 @@ if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then cd website npm install + npm run gatherDocs GIT_USER=$GIT_USER CURRENT_BRANCH=master npm run publish-gh-pages else echo 'Not deploying the website' diff --git a/website/gatherDocs.js b/website/gatherDocs.js index 53e1166719..ed3dc328d3 100644 --- a/website/gatherDocs.js +++ b/website/gatherDocs.js @@ -107,6 +107,32 @@ async function generateDocumentation(versions, tempDir) { } } +async function generate(versions, currentAttempt = 1) { + const maxAttempts = 3; + let success; + const tempDir = fs.mkdtempSync('detox-documentation-generation'); + try { + await generateDocumentation(versions, tempDir); + success = true; + } catch (e) { + console.log('Error while generating documentation', e); + success = false; + } finally { + await cleanUp(tempDir); + } + + if (success) { + return; + } + + if (currentAttempt < maxAttempts) { + await generate(versions, currentAttempt + 1); + } else { + console.error(`Generation failed ${maxAttempts} times, there seems to be a real problem, please file an issue`); + process.exit(1); + } +} + async function cleanUp(tempDir) { console.log('Cleanup temporary clone'); await fs.remove(tempDir); @@ -115,9 +141,7 @@ async function cleanUp(tempDir) { (async function() { const versions = await getVersions(); await cleanupExistingVersions(); - fs.writeFileSync('./versions.json', JSON.stringify(versions), 'utf8'); - const tempDir = fs.mkdtempSync('detox-documentation-generation'); - await generateDocumentation(versions, tempDir) - await cleanUp(tempDir); + + await generate(versions); })();