Skip to content

Commit 79266b5

Browse files
committed
Chore: add .travis.yml to auto-deploy
1 parent 3b574a3 commit 79266b5

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sudo: false
2+
3+
branches:
4+
only:
5+
- master
6+
7+
language: node_js
8+
node_js: "8"
9+
10+
script:
11+
- git config --local user.name "Travis CI" && npm run deploy

scripts/deploy.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
const sh = require("shelljs")
88
const version = require("../package.json").version
9+
const ATOKEN = process.env.ATOKEN //eslint-disable-line no-process-env
910

1011
//------------------------------------------------------------------------------
1112
// Helpers
@@ -46,16 +47,30 @@ function exec(command) {
4647
// Main
4748
//------------------------------------------------------------------------------
4849

50+
// Build.
4951
exec(`git checkout v${version}`)
5052
exec("npm run build")
53+
54+
// Load gh-pages.
55+
if (ATOKEN) {
56+
exec("git fetch --depth=1 https://github.com/mysticatea/vue-eslint-demo.git gh-pages:gh-pages")
57+
}
5158
exec("git checkout gh-pages")
5259

53-
if (String(sh.cat("dist/versions.json")) !== String(sh.cat("versions.json"))) {
60+
// Check versions.
61+
const oldVersions = String(sh.cat("versions.json"))
62+
const newVersions = String(sh.cat("dist/versions.json"))
63+
sh.echo(`OLD: ${oldVersions}`)
64+
sh.echo(`NEW: ${newVersions}`)
65+
66+
// Deploy.
67+
if (newVersions !== oldVersions) {
5468
rm("-rf", "vs", "index.*")
5569
cp("-r", "dist/*", ".")
5670
exec("git add -A")
5771
exec("git commit -m \"Update: website\"")
58-
exec("git push")
72+
exec(`git push${ATOKEN ? ` https://mysticatea:${ATOKEN}@github.com/mysticatea/vue-eslint-demo.git gh-pages:gh-pages` : ""}`)
5973
}
6074

75+
// Back to master.
6176
exec("git checkout master")

0 commit comments

Comments
 (0)