Skip to content

Commit

Permalink
ci(deploy-docs): Try with promises so that only 1 deploy at a time ha…
Browse files Browse the repository at this point in the history
…ppens.
  • Loading branch information
ryanoglesby08 committed Aug 16, 2017
1 parent a9ff5ca commit c9b1738
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions scripts/deploy-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
// s3-website: https://github.com/klaemo/s3-website


if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
console.error("'AWS_ACCESS_KEY_ID' and 'AWS_SECRET_ACCESS_KEY' must be available in the environment.");
process.exit(1);
}
// if (!process.env.AWS_ACCESS_KEY_ID || !process.env.AWS_SECRET_ACCESS_KEY) {
// console.error("'AWS_ACCESS_KEY_ID' and 'AWS_SECRET_ACCESS_KEY' must be available in the environment.");
// process.exit(1);
// }


const resolvePath = require('path').resolve;
Expand All @@ -35,7 +35,7 @@ const config = {
const s3 = new AWS.S3({ region: config.region });


const deployToS3 = (prefix) => {
const deployToS3 = (prefix) => new Promise((resolve, reject) => {
const deployConfig = Object.assign(config, { prefix });

console.log('Deploying to s3...');
Expand All @@ -44,11 +44,14 @@ const deployToS3 = (prefix) => {
deploy(s3, deployConfig, (err, website) => {
if (err) {
console.error(err);
reject(err);
}
else {
console.log(website);
resolve();
}

console.log(website);
});
};
});

// Continue to deploy to the thorium bucket because http://tds.telus.com points there
const deployToS3_deprecated = () => {
Expand All @@ -62,7 +65,7 @@ const deployToS3_deprecated = () => {

deploy(s3, deployConfig, (err, website) => {
if (err) {
console.error(err);
throw err;
}

console.log(website);
Expand All @@ -71,13 +74,13 @@ const deployToS3_deprecated = () => {


if (env === 'production') {
deployToS3('latest');
deployToS3(`v${version}`);

// Continue to deploy to the thorium bucket because http://tds.telus.com points there
// TODO: Rip this out when the domain name is pointed at the new bucket: TDS-286
deployToS3_deprecated();
deployToS3('latest')
.then(() => deployToS3(`v${version}`))
// Continue to deploy to the thorium bucket because http://tds.telus.com points there
// TODO: Rip this out when the domain name is pointed at the new bucket: TDS-286
.then(() => deployToS3_deprecated());
}
else {
deployToS3('staging');
deployToS3('ryan.test.1');
}

0 comments on commit c9b1738

Please sign in to comment.