Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e4b879d

Browse files
committed
fix production aliasing and integrate discord webhook
1 parent d2a7ebc commit e4b879d

File tree

4 files changed

+49
-14
lines changed

4 files changed

+49
-14
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ env:
2020
nDYIe5Cw1FgD1Iqv2FKRG5Q6Jvvml4ovKPjMRD3BBWinPHe6xbZGtPi0P/Jqt6PFmu5o3aiWQO4ffYnFYUW8N8Tu86RMr0sLQ7Sv6MiE0JxL+7Y+VBZ9h1i9MARiTFQRUw9lrToNa13bnuGy5YNfx4nVUo63vluRTCW6AZd0h01tgEjbhTAamWf1z/n26ACMNJSr2iQ7coakLwpsQvdXMcUe5tAduzoQtLb8DiXdbXO+D7Oepl4dQvOfosa14wW5Z6MN6Y/AxxJ246Cngm3hgZF7IpLCD49H7shXHHSaIcYkJtnSRozKSBEdz34+Jqw+278vcWOA4n2advAhWd2oCAUa0drmu8Nu2Obtrx4oAUQhDwBxfQhbmXpen2Ry5DKp86AurTxgXc+n6bPfjwGdjha2u6cd1fCwpTu5pgnOeX101U/Bu68tAz/EIErCDxHDW/WyrBkVKG3rkABjv3pse4ZJuMy3eeKp+8o2P29b77GHxhKdEw4SvZSfdfnVooABcC6p/sqcumuTvJn20AZkBdhuxGDYSEfNecKPAEHRV8nUQUbMVT7bImQAgl4O4QhHcOfrthbNnQJM94DX0Z2xRQ5sdRmzhe4Ob771EUByNdMO7k2O1KsJAWQ78KhTdOJKoiIp2sH9zRGCTjnTIoCDJx4zBTGHpqV0+R4ltth7T4Q=
2121
- secure: >-
2222
Gj+PgZbNTBJ4C/5WZPjMicUWYJCt+gVnuDNjJCyahqFOOHvTowl3WKoeRwxSf/it9xqW/su6JrehgQixn0OVhkVWL8FVgs5TCvFtFBdYTHTrPIi+2T0sulp/NscsDG2hh3d6WD+AnC4u5QtRkTuh7IZEpLkRTHBwedRhfjvPOQaaT5wZ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aYuHB8XHwVQPDXTXGSOsGcp6bwxWtMKeQdg0x6kCND4xZv9MK/02J0XuOOEpj+8Bb5gRNaB6eQqqIppKf6lG9OJ+zSBezshaeapS843j+vOazPB8FpQpjRpfKNRI=

package.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "xo",
8-
"lint":
9-
"prettier 'utils/**/*.js' 'components/**/*.js' 'pages/**/*.js' 'lib/**/*.js' 'hocs/**/*.js' '*.js' --write --single-quote --print-width='80' --trailing-comma='all' && xo --fix",
8+
"lint": "prettier 'utils/**/*.js' 'components/**/*.js' 'pages/**/*.js' 'lib/**/*.js' 'hocs/**/*.js' '*.js' --write --single-quote --print-width='80' --trailing-comma='all' && xo --fix",
109
"precommit": "lint-staged",
1110
"analyze": "cross-env ANALYZE=1 next build",
1211
"dev": "cross-env NODE_ENV=development next",
@@ -16,15 +15,24 @@
1615
},
1716
"xo": {
1817
"parser": "babel-eslint",
19-
"extends": ["prettier", "prettier/react", "plugin:react/recommended"],
20-
"env": ["browser", "node"],
18+
"extends": [
19+
"prettier",
20+
"prettier/react",
21+
"plugin:react/recommended"
22+
],
23+
"env": [
24+
"browser",
25+
"node"
26+
],
2127
"rules": {
2228
"linebreak-style": 0,
2329
"react/display-name": 0,
2430
"react/prop-types": 0
2531
},
2632
"space:": 2,
27-
"ignores": ["next.config.js"]
33+
"ignores": [
34+
"next.config.js"
35+
]
2836
},
2937
"lint-staged": {
3038
"*.js": [
@@ -53,6 +61,7 @@
5361
"semantic-ui-react": "^0.71.3"
5462
},
5563
"devDependencies": {
64+
"axios": "0.16.2",
5665
"babel-eslint": "^7.2.3",
5766
"babel-plugin-lodash": "^3.2.11",
5867
"cross-env": "^5.0.2",

scripts/now.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const spawn = require('cross-spawn');
66
const travisAfterAll = require('travis-after-all');
77
const urlRegex = require('url-regex');
88
const argv = require('yargs').argv;
9+
const axios = require('axios');
910

1011
const nowCli = require.resolve('now/download/dist/now');
1112

@@ -15,6 +16,7 @@ if (!process.env.CI || !process.env.TRAVIS) {
1516

1617
const githubToken = process.env.GH_TOKEN;
1718
const nowToken = process.env.NOW_TOKEN;
19+
const discordHook = process.env.DISCORD_HOOK;
1820

1921
if (!githubToken) {
2022
throw new Error('Missing required environment variable GH_TOKEN');
@@ -68,10 +70,6 @@ function deploy(context, sha) {
6870
const alias = context === 'production' && process.env.NOW_ALIAS;
6971
let stdout = '';
7072

71-
if (alias) {
72-
args.push(...['--alias', alias]);
73-
}
74-
7573
if (argv.p || argv.public) {
7674
args.push(...['-p']);
7775
}
@@ -102,13 +100,26 @@ function deploy(context, sha) {
102100
});
103101

104102
child.on('close', () => {
105-
const target_url = alias || getUrl(stdout);
103+
const target_url = getUrl(stdout);
104+
const comment = url =>
105+
`### New Δ Now ${context} deployment complete\n- ✅ **Build Passed**\n- 🚀 **URL** : ${url}\n---\nNote: **This is autogenerated through travis-ci build**`;
106+
if (alias) {
107+
spawn(nowCli, ['alias', target_url, alias]);
108+
axios
109+
.post(discordHook, {
110+
content: comment(`${alias} and https://coderplex.org`),
111+
username: 'coderplex-bot',
112+
})
113+
.then(() => {
114+
console.log(`SUCCESS posted to discord`);
115+
})
116+
.catch(console.log);
117+
}
106118
if (ghPR) {
107-
const comment = `### New Δ Now ${context} deployment complete\n- ✅ **Build Passed**\n- 🚀 **Staging URL** : ${target_url}\n---\nNote: **This is autogenerated through Travis build**`;
108-
console.log(comment);
119+
console.log(comment(target_url));
109120
ghPR.createComment(
110121
{
111-
body: comment,
122+
body: comment(target_url),
112123
},
113124
(err, res) => {
114125
console.log(err, res);

yarn.lock

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,13 @@ aws4@^1.2.1, aws4@^1.6.0:
315315
version "1.6.0"
316316
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e"
317317

318+
319+
version "0.16.2"
320+
resolved "https://registry.yarnpkg.com/axios/-/axios-0.16.2.tgz#ba4f92f17167dfbab40983785454b9ac149c3c6d"
321+
dependencies:
322+
follow-redirects "^1.2.3"
323+
is-buffer "^1.1.5"
324+
318325
babel-code-frame@^6.16.0, babel-code-frame@^6.22.0, babel-code-frame@^6.26.0:
319326
version "6.26.0"
320327
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
@@ -1629,7 +1636,7 @@ dateformat@^1.0.11, dateformat@^1.0.12:
16291636
get-stdin "^4.0.1"
16301637
meow "^3.3.0"
16311638

1632-
debug@2, [email protected], debug@^2.1.1, debug@^2.2.0, debug@^2.6.8:
1639+
debug@2, [email protected], debug@^2.1.1, debug@^2.2.0, debug@^2.6.8, debug@^2.6.9:
16331640
version "2.6.9"
16341641
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
16351642
dependencies:
@@ -2378,6 +2385,12 @@ [email protected]:
23782385
debug "^2.2.0"
23792386
stream-consume "^0.1.0"
23802387

2388+
follow-redirects@^1.2.3:
2389+
version "1.2.5"
2390+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.2.5.tgz#ffd3e14cbdd5eaa72f61b6368c1f68516c2a26cc"
2391+
dependencies:
2392+
debug "^2.6.9"
2393+
23812394
for-in@^1.0.1:
23822395
version "1.0.2"
23832396
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"

0 commit comments

Comments
 (0)