8000 Merge pull request #1689 from tivac/auto-publish · MithrilJS/mithril.js@622bd6e · GitHub
[go: up one dir, main page]

Skip to content

Commit 622bd6e

Browse files
authored
Merge pull request #1689 from tivac/auto-publish
Docs auto-push to gh-pages branch
2 parents a2ee51b + 43f050a commit 622bd6e

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

.travis.yml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,54 @@ cache:
1010
directories:
1111
- node_modules
1212

13-
# Custom install step so the travis scripts don't need to be in package.json
13+
# Custom install step so the travis-only stuff doesn't need to be in package.json
1414
install:
1515
- npm install
16-
- npm install @alrra/travis-scripts@^3.0.1
16+
- npm install @alrra/travis-scripts@^3.0.1 gh-pages@^0.12.0
1717

1818
# Bundle before running tests so the bundle is always up-to-date
1919
before_script: npm run build
2020

2121
# This is the default, but leaving so it is obvious
2222
# script: npm test
2323

24-
# After a successful build create bundles & commit back to the repo
24+
# After a successful build commit changes back to repo
2525
after_success:
2626
- |
27+
# Set up SSH environment
28+
$(npm bin)/set-up-ssh \
29+
--key "$encrypted_8b86e0359d64_key" \
30+
--iv "$encrypted_8b86e0359d64_iv" \
31+
--path-encrypted-key "./.deploy.enc"
32+
33+
# Commit bundle changes generated in before_script step
34+
# --commands is a weird no-op but required for commit-changes to run
35+
# --branch arg is to ensure this only runs against the `next` branch
36+
$(npm bin)/commit-changes \
37+
--commands "echo committing" \
38+
--commit-message "Bundled output for commit $TRAVIS_COMMIT [skip ci]" \
39+
--branch "next"
2740
28-
# Only want to commit when building a push on whatever $BRANCH is
41+
# Only want to commit docs when building pushes on master &
42+
# this doesn't have the built-in branch protection likt commit-changes
2943
if [ "$TRAVIS_EVENT_TYPE" == "push" ] && \
30-
[ "$TRAVIS_BRANCH" == "$BRANCH" ] && \
31-
[ "$TRAVIS_REPO_SLUG" == "$REPO" ]
44+
[ "$TRAVIS_BRANCH" == "master" ] && \
45+
[ "$TRAVIS_REPO_SLUG" == "lhorie/mithril.js" ]
8000 3246
then
33-
# Set up SSH environment
34-
$(npm bin)/set-up-ssh \
35-
--key "$encrypted_8b86e0359d64_key" \
36-
--iv "$encrypted_8b86e0359d64_iv" \
37-
--path-encrypted-key "./.deploy.enc"
47+
# Generate docs
48+
$(npm-bin) run gendocs
3849
39-
# Commit changes (if there were any) from running build earlier
40-
$(npm bin)/commit-changes \
41-
--commands "echo committing" \
42-
--commit-message "Bundled output for commit $TRAVIS_COMMIT [skip ci]" \
43-
--branch "$BRANCH"
50+
# Commit docs to gh-pages branch
51+
# Using --add to ensure that archived versions aren't lost
52+
# Using --repo to force it to go over SSH so the saved keys are used (tschaub/gh-pages#160)
53+
$(npm bin)/gh-pages --dist ./dist --add --repo "git@github.com:lhorie/mithril.js.git"
4454
else
45-
echo "Not submitting build artifacts"
55+
echo "Not submitting documentation updates"
4656
fi
47-
57+
4858
# Environment configuration
4959
env:
5060
global:
51-
# Restrict the branch this will activate on
52-
- BRANCH=next
53-
- REPO=lhorie/mithril.js
54-
5561
# Set up GH_USER_EMAIL & GH_USER_NAME env variables used by travis-scripts package
5662
- secure: Xvqvm3+PvJu/rs3jl/NNn0RWLkkLkIoPHiL0GCfVRaywgjCYVN02g54NVvIDaOfybqPmu9E6PJFVs92vhF34NMFQHf4EWskynusIGV271R2BV0i+OJBfLMuLgiwm6zRn7/Zw4JvWIUGEwcnlz0qxbqdHsS0SOR3fIkFzePickW0=
5763
- secure: Rf/ldEO9d4vItJhe6EmqWpFAyCARzoCb422nHnjr1hYJknnwIXpgyZ1C/7On/9o7rWPPf+8WcHC/rgjK2rthKCldzdG5I60LfWSNzap9lk3Aa4TpSCoDBuEp7JVvDr5tc3rKnBXVT71hOay7RSx1StWzXiJs9mjaeVMJzYzRT78=

docs/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mithril.js.org

docs/generate.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ var path = require("path")
33
var marked = require("marked")
44
var layout = fs.readFileSync("./docs/layout.html", "utf-8")
55
var version = JSON.parse(fs.readFileSync("./package.json", "utf-8")).version
6-
try {fs.mkdirSync("../mithril")} catch (e) {}
7-
try {fs.mkdirSync("../mithril/archive")} catch (e) {}
8-
try {fs.mkdirSync("../mithril/archive/v" + version)} catch (e) {}
9-
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib")} catch (e) {}
10-
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib/prism")} catch (e) {}
11-
try {fs.mkdirSync("../mithril/lib")} catch (e) {}
12-
try {fs.mkdirSync("../mithril/lib/prism")} catch (e) {}
6+
try {fs.mkdirSync("./dist")} catch (e) {}
7+
try {fs.mkdirSync("./dist/archive")} catch (e) {}
8+
try {fs.mkdirSync("./dist/archive/v" + version)} catch (e) {}
9+
try {fs.mkdirSync("./dist/archive/v" + version + "/lib")} catch (e) {}
10+
try {fs.mkdirSync("./dist/archive/v" + version + "/lib/prism")} catch (e) {}
11+
try {fs.mkdirSync("./dist/lib")} catch (e) {}
12+
try {fs.mkdirSync("./dist/lib/prism")} catch (e) {}
1313

1414
var guides = fs.readFileSync("docs/guides.md", "utf-8")< 8000 /div>
1515
var methods = fs.readFileSync("docs/methods.md", "utf-8")
@@ -55,12 +55,12 @@ function generate(pathname) {
5555
.replace(/<h(.) id="([^"]+?)">(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors
5656
return "<h" + n + " id=\"" + text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/<a.*?>.+?<\/a>/g, "").replace(/\.|\[|\]|&quot;|\/|\(|\)/g, "").replace(/\s/g, "-") + "\">" + text + "</h" + n + ">"
5757
})
58-
fs.writeFileSync("../mithril/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
59-
fs.writeFileSync("../mithril/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
58+
fs.writeFileSync("./dist/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
59+
fs.writeFileSync("./dist/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
6060
}
6161
else if (!pathname.match(/lint|generate/)) {
62-
fs.writeFileSync("../mithril/archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
63-
fs.writeFileSync("../mithril/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
62+
fs.writeFileSync("./dist/archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
63+
fs.writeFileSync("./dist/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
6464
}
6565
}
6666
}

0 commit comments

Comments
 (0)
0