1
1
#! /usr/bin/env node
2
-
2
+ /* eslint-disable camelcase */
3
3
const github = require ( 'octonode' ) ;
4
4
const normalizeUrl = require ( 'normalize-url' ) ;
5
5
const spawn = require ( 'cross-spawn' ) ;
@@ -26,6 +26,14 @@ if (!nowToken) {
26
26
27
27
const client = github . client ( githubToken ) ;
28
28
const ghRepo = client . repo ( process . env . TRAVIS_REPO_SLUG ) ;
29
+ let ghPR ;
30
+
31
+ if ( process . env . TRAVIS_PULL_REQUEST ) {
32
+ ghPR = client . pr (
33
+ process . env . TRAVIS_REPO_SLUG ,
34
+ process . env . TRAVIS_PULL_REQUEST ,
35
+ ) ;
36
+ }
29
37
30
38
function noop ( ) { }
31
39
@@ -46,7 +54,15 @@ function deploy(context, sha) {
46
54
noop ,
47
55
) ;
48
56
49
- const args = [ '--token' , nowToken , '--no-clipboard' ] ;
57
+ const args = [
58
+ '--token' ,
59
+ nowToken ,
60
+ '--team' ,
61
+ 'coderplex' ,
62
+ '--no-clipboard' ,
63
+ '-n' ,
64
+ 'coderplex-app' ,
65
+ ] ;
50
66
const alias = context === 'production' && process . env . NOW_ALIAS ;
51
67
let stdout = '' ;
52
68
@@ -84,18 +100,34 @@ function deploy(context, sha) {
84
100
} ) ;
85
101
86
102
child . on ( 'close' , ( ) => {
87
- const targetUrl = alias || getUrl ( stdout ) ;
103
+ const target_url = alias || getUrl ( stdout ) ;
88
104
89
105
ghRepo . status (
90
106
sha ,
91
107
{
92
108
context,
93
- targetUrl ,
109
+ target_url ,
94
110
state : 'success' ,
95
111
description : `Δ Now ${ context } deployment complete` ,
96
112
} ,
97
113
noop ,
98
114
) ;
115
+ if ( ghPR ) {
116
+ const comment = `
117
+ ### Δ Now ${ context } deployment complete
118
+ - ✅ **Build Passed**
119
+ - 🚀 **Staging URL** : ${ target_url }
120
+ ---
121
+ Note: **This is autogenerated through Travis build**
122
+ ` ;
123
+ ghPR . createComment (
124
+ {
125
+ body : comment ,
126
+ commit_id : process . env . TRAVIS_COMMIT ,
127
+ } ,
128
+ noop ,
129
+ ) ;
130
+ }
99
131
} ) ;
100
132
}
101
133
0 commit comments