mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 15:47:53 -05:00
create announce.js to announce deploys to slack
This commit is contained in:
parent
cafa592789
commit
9a498d6b79
2 changed files with 48 additions and 1 deletions
46
bin/announce.js
Normal file
46
bin/announce.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// this will announce that a deploy successfully finished into slack
|
||||||
|
|
||||||
|
const https = require('https');
|
||||||
|
|
||||||
|
let environment = process.env.SCRATCH_ENV || 'unknown environment';
|
||||||
|
|
||||||
|
let branch = process.env.CIRCLE_BRANCH || 'unknown branch';
|
||||||
|
|
||||||
|
let urlEng = process.env.SLACK_WEBHOOK_ENGINEERING;
|
||||||
|
let urlMod = process.env.SLACK_WEBHOOK_MODS;
|
||||||
|
let urlNotifications = process.env.SLACK_WEBHOOK_CIRCLECI_NOTIFICATIONS;
|
||||||
|
|
||||||
|
let announcement = {text: `scratch-www has deployed branch ${branch} to ${environment}.`};
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const postMessage = (url, message, channelName) => {
|
||||||
|
let data = JSON.stringify(message);
|
||||||
|
const req = https.request(url, options, res => {
|
||||||
|
console.log(`statusCode: ${res.statusCode}`); // eslint-disable-line no-console
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
process.stdout.write(`announced to ${channelName}\n` + JSON.stringify(message) + '\n');
|
||||||
|
} else {
|
||||||
|
process.stdout.write(`FAILED to announce to slack`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', error => {
|
||||||
|
console.error(error); // eslint-disable-line no-console
|
||||||
|
});
|
||||||
|
|
||||||
|
req.write(data);
|
||||||
|
req.end();
|
||||||
|
};
|
||||||
|
|
||||||
|
postMessage(urlNotifications, announcement, '#circleci-notifications');
|
||||||
|
|
||||||
|
if (environment === 'production'){
|
||||||
|
postMessage(urlEng, announcement, '#engineering');
|
||||||
|
postMessage(urlMod, announcement, '#scratch-mods');
|
||||||
|
}
|
|
@ -18,7 +18,7 @@
|
||||||
"test:coverage": "tap ./test/{unit-legacy,localization-legacy}/ --coverage --coverage-report=lcov",
|
"test:coverage": "tap ./test/{unit-legacy,localization-legacy}/ --coverage --coverage-report=lcov",
|
||||||
"build": "npm run clean && npm run translate && NODE_OPTIONS=--max_old_space_size=8000 webpack --bail",
|
"build": "npm run clean && npm run translate && NODE_OPTIONS=--max_old_space_size=8000 webpack --bail",
|
||||||
"clean": "rm -rf ./build && rm -rf ./intl && mkdir -p build && mkdir -p intl",
|
"clean": "rm -rf ./build && rm -rf ./intl && mkdir -p build && mkdir -p intl",
|
||||||
"deploy": "npm run deploy:s3 && npm run deploy:fastly",
|
"deploy": "npm run deploy:s3 && npm run deploy:fastly && npm run deploy:announce",
|
||||||
"deploy:fastly": "node ./bin/configure-fastly.js",
|
"deploy:fastly": "node ./bin/configure-fastly.js",
|
||||||
"deploy:s3": "npm run deploy:s3:all && npm run deploy:s3:svg && npm run deploy:s3:js && npm run deploy:s3:css",
|
"deploy:s3": "npm run deploy:s3:all && npm run deploy:s3:svg && npm run deploy:s3:js && npm run deploy:s3:css",
|
||||||
"deploy:s3cmd": "s3cmd sync -P --delete-removed --add-header=Cache-Control:no-cache,public,max-age=3600 --add-header=x-amz-meta-surrogate-key:static-assets",
|
"deploy:s3cmd": "s3cmd sync -P --delete-removed --add-header=Cache-Control:no-cache,public,max-age=3600 --add-header=x-amz-meta-surrogate-key:static-assets",
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
"deploy:s3:svg": "npm run deploy:s3cmd -- --exclude '*' --include '*.svg' --mime-type 'image/svg+xml' ./build/ s3://$S3_BUCKET_NAME/",
|
"deploy:s3:svg": "npm run deploy:s3cmd -- --exclude '*' --include '*.svg' --mime-type 'image/svg+xml' ./build/ s3://$S3_BUCKET_NAME/",
|
||||||
"deploy:s3:js": "npm run deploy:s3cmd -- --exclude '*' --include '*.js' --mime-type 'application/javascript' ./build/ s3://$S3_BUCKET_NAME/",
|
"deploy:s3:js": "npm run deploy:s3cmd -- --exclude '*' --include '*.js' --mime-type 'application/javascript' ./build/ s3://$S3_BUCKET_NAME/",
|
||||||
"deploy:s3:css": "npm run deploy:s3cmd -- --exclude '*' --include '*.css' --mime-type 'text/css' ./build/ s3://$S3_BUCKET_NAME/",
|
"deploy:s3:css": "npm run deploy:s3cmd -- --exclude '*' --include '*.css' --mime-type 'text/css' ./build/ s3://$S3_BUCKET_NAME/",
|
||||||
|
"deploy:announce": "node ./bin/announce.js",
|
||||||
"i18n:push": "./bin/tx-push-www --execute",
|
"i18n:push": "./bin/tx-push-www --execute",
|
||||||
"translate:urls": "node ./bin/get-localized-urls localized-urls.json",
|
"translate:urls": "node ./bin/get-localized-urls localized-urls.json",
|
||||||
"translate:files": "node ./bin/build-locales node_modules/scratch-l10n/www intl",
|
"translate:files": "node ./bin/build-locales node_modules/scratch-l10n/www intl",
|
||||||
|
|
Loading…
Reference in a new issue