Skip to content

Commit

Permalink
Deploy script (KEY-328) (auth0#190)
Browse files Browse the repository at this point in the history
* added deploy script for automatic upload the rules.json to the aws s3

* exit with code 1 in case of error
  • Loading branch information
zxan1285 authored and fyockm committed Dec 3, 2018
1 parent 963ce1a commit 61c53ad
Show file tree
Hide file tree
Showing 5 changed files with 1,114 additions and 959 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ build/Release
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules

#secrets
.env
38 changes: 38 additions & 0 deletions deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const aws = require('aws-sdk');
const rules = require('./rules.json');
require('dotenv').config();

(function () {
if (!process.env.S3_ACCESS_KEY || !process.env.S3_SECRET || !process.env.S3_REGION || !process.env.S3_BUCKET) {
console.log('AWS S3 settings missing. S3_ACCESS_KEY, S3_SECRET, S3_REGION and S3_BUCKET settings are required.');
process.exit(1);
}

console.log(`Deploying rules.json into ${process.env.S3_BUCKET} bucket...`);

const S3 = new aws.S3({
accessKeyId: process.env.S3_ACCESS_KEY,
secretAccessKey: process.env.S3_SECRET,
sessionToken: process.env.S3_SESSION_TOKEN,
region: process.env.S3_REGION,
params: {
Bucket: process.env.S3_BUCKET
}
});

const params = {
Body: JSON.stringify(rules),
Key: 'rules/rules.json',
ContentType: 'application/json'
};

return S3.putObject(params, function(err) {
if (err) {
console.log(err);
process.exit(1);
}

console.log('rules.json deployed successfully.');
process.exit();
});
})();
Loading

0 comments on commit 61c53ad

Please sign in to comment.