浏览代码

Merge pull request #1527 from ckeditor/t/1526

Internal: Added a missing `CRON` type of a build to the script which sends notifications to our Slack. Closes #1526.
Piotrek Koszuliński 6 年之前
父节点
当前提交
f8e2d6818e
共有 1 个文件被更改,包括 19 次插入11 次删除
  1. 19 11
      scripts/notify-travis-status.js

+ 19 - 11
scripts/notify-travis-status.js

@@ -21,13 +21,23 @@ It also has some dependencies:
 
 const buildBranch = process.env.TRAVIS_BRANCH;
 
+const acceptedBranches = [
+	'master',
+	'master-revisions'
+];
+
+const acceptedEvents = [
+	'push',
+	'cron'
+];
+
 // Send a notification only for main branches...
-if ( buildBranch !== 'master' && buildBranch !== 'master-revisions' ) {
+if ( !acceptedBranches.includes( buildBranch ) ) {
 	process.exit();
 }
 
-// ...and "push" builds...
-if ( process.env.TRAVIS_EVENT_TYPE !== 'push' ) {
+// ...and an event that triggered the build is correct...
+if ( !acceptedEvents.includes( process.env.TRAVIS_EVENT_TYPE ) ) {
 	process.exit();
 }
 
@@ -48,7 +58,11 @@ const commitUrl = `https://github.com/${ owner }/${ repo }/commit/${ buildCommit
 const shortCommit = buildCommit.substring( 0, 7 );
 const execTime = getExecutionTime( parseInt( process.env.END_TIME ), parseInt( process.env.START_TIME ) );
 
-const messageOptions = {
+slack.onError = err => {
+	console.log( 'API error occurred:', err );
+};
+
+slack.send( {
 	icon_url: 'https://a.slack-edge.com/66f9/img/services/travis_36.png',
 	unfurl_links: 1,
 	username: 'Travis CI',
@@ -84,13 +98,7 @@ const messageOptions = {
 			]
 		},
 	]
-};
-
-slack.onError = err => {
-	console.log( 'API error occurred:', err );
-};
-
-slack.send( messageOptions );
+} );
 
 /**
  * Returns an object that compares two dates.