1
1
#! /usr/bin/env node
2
2
/* eslint-disable camelcase */
3
+ console . log ( `PR: ${ process . env . TRAVIS_PULL_REQUEST } ` ) ;
3
4
const github = require ( 'octonode' ) ;
4
5
const normalizeUrl = require ( 'normalize-url' ) ;
5
6
const spawn = require ( 'cross-spawn' ) ;
@@ -24,7 +25,7 @@ if (!nowToken) {
24
25
throw new Error ( 'Missing required environment variable NOW_TOKEN' ) ;
25
26
}
26
27
27
- console . log ( process . env . TRAVIS_PULL_REQUEST ) ;
28
+ console . log ( `PR: ${ process . env . TRAVIS_PULL_REQUEST } ` ) ;
28
29
29
30
const client = github . client ( githubToken ) ;
30
31
const ghRepo = client . repo ( process . env . TRAVIS_REPO_SLUG ) ;
@@ -41,7 +42,7 @@ function noop() {}
41
42
42
43
function getUrl ( content ) {
43
44
const urls = content . match ( urlRegex ( ) ) || [ ] ;
44
-
45
+ console . log ( `PR: ${ process . env . TRAVIS_PULL_REQUEST } ` ) ;
45
46
return urls . map ( url => normalizeUrl ( url . trim ( ) . replace ( / \. + $ / , '' ) ) ) [ 0 ] ;
46
47
}
47
48
@@ -103,24 +104,11 @@ function deploy(context, sha) {
103
104
104
105
child . on ( 'close' , ( ) => {
105
106
const target_url = alias || getUrl ( stdout ) ;
106
-
107
- ghRepo . status (
108
- sha ,
109
- {
110
- context,
111
- target_url,
112
- state : 'success' ,
113
- description : `Δ Now ${ context } deployment complete` ,
114
- } ,
115
- noop ,
116
- ) ;
117
107
if ( ghPR ) {
118
108
const comment = `
119
- ### Δ Now ${ context } deployment complete
120
- - ✅ **Build Passed**
121
- - 🚀 **Staging URL** : ${ target_url }
122
- ---
123
- Note: **This is autogenerated through Travis build**
109
+ Δ Now ${ context } deployment complete
110
+ Staging URL : ${ target_url }
111
+ Note: This is autogenerated through Travis build
124
112
` ;
125
113
ghPR . createComment (
126
114
{
@@ -131,6 +119,16 @@ function deploy(context, sha) {
131
119
} else {
132
120
console . log ( 'No PR found' ) ;
133
121
}
122
+ ghRepo . status (
123
+ sha ,
124
+ {
125
+ context,
126
+ target_url,
127
+ state : 'success' ,
128
+ description : `Δ Now ${ context } deployment complete` ,
129
+ } ,
130
+ noop ,
131
+ ) ;
134
132
} ) ;
135
133
}
136
134
0 commit comments