Merge pull request #1689 from tivac/auto-publish
Docs auto-push to gh-pages branch
This commit is contained in:
commit
622bd6e165
3 changed files with 40 additions and 33 deletions
48
.travis.yml
48
.travis.yml
|
|
@ -10,10 +10,10 @@ cache:
|
||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
|
|
||||||
# Custom install step so the travis scripts don't need to be in package.json
|
# Custom install step so the travis-only stuff doesn't need to be in package.json
|
||||||
install:
|
install:
|
||||||
- npm install
|
- npm install
|
||||||
- npm install @alrra/travis-scripts@^3.0.1
|
- npm install @alrra/travis-scripts@^3.0.1 gh-pages@^0.12.0
|
||||||
|
|
||||||
# Bundle before running tests so the bundle is always up-to-date
|
# Bundle before running tests so the bundle is always up-to-date
|
||||||
before_script: npm run build
|
before_script: npm run build
|
||||||
|
|
@ -21,37 +21,43 @@ before_script: npm run build
|
||||||
# This is the default, but leaving so it is obvious
|
# This is the default, but leaving so it is obvious
|
||||||
# script: npm test
|
# script: npm test
|
||||||
|
|
||||||
# After a successful build create bundles & commit back to the repo
|
# After a successful build commit changes back to repo
|
||||||
after_success:
|
after_success:
|
||||||
- |
|
- |
|
||||||
|
# Set up SSH environment
|
||||||
|
$(npm bin)/set-up-ssh \
|
||||||
|
--key "$encrypted_8b86e0359d64_key" \
|
||||||
|
--iv "$encrypted_8b86e0359d64_iv" \
|
||||||
|
--path-encrypted-key "./.deploy.enc"
|
||||||
|
|
||||||
# Only want to commit when building a push on whatever $BRANCH is
|
# Commit bundle changes generated in before_script step
|
||||||
|
# --commands is a weird no-op but required for commit-changes to run
|
||||||
|
# --branch arg is to ensure this only runs against the `next` branch
|
||||||
|
$(npm bin)/commit-changes \
|
||||||
|
--commands "echo committing" \
|
||||||
|
--commit-message "Bundled output for commit $TRAVIS_COMMIT [skip ci]" \
|
||||||
|
--branch "next"
|
||||||
|
|
||||||
|
# Only want to commit docs when building pushes on master &
|
||||||
|
# this doesn't have the built-in branch protection likt commit-changes
|
||||||
if [ "$TRAVIS_EVENT_TYPE" == "push" ] && \
|
if [ "$TRAVIS_EVENT_TYPE" == "push" ] && \
|
||||||
[ "$TRAVIS_BRANCH" == "$BRANCH" ] && \
|
[ "$TRAVIS_BRANCH" == "master" ] && \
|
||||||
[ "$TRAVIS_REPO_SLUG" == "$REPO" ]
|
[ "$TRAVIS_REPO_SLUG" == "lhorie/mithril.js" ]
|
||||||
then
|
then
|
||||||
# Set up SSH environment
|
# Generate docs
|
||||||
$(npm bin)/set-up-ssh \
|
$(npm-bin) run gendocs
|
||||||
--key "$encrypted_8b86e0359d64_key" \
|
|
||||||
--iv "$encrypted_8b86e0359d64_iv" \
|
|
||||||
--path-encrypted-key "./.deploy.enc"
|
|
||||||
|
|
||||||
# Commit changes (if there were any) from running build earlier
|
# Commit docs to gh-pages branch
|
||||||
$(npm bin)/commit-changes \
|
# Using --add to ensure that archived versions aren't lost
|
||||||
--commands "echo committing" \
|
# Using --repo to force it to go over SSH so the saved keys are used (tschaub/gh-pages#160)
|
||||||
--commit-message "Bundled output for commit $TRAVIS_COMMIT [skip ci]" \
|
$(npm bin)/gh-pages --dist ./dist --add --repo "git@github.com:lhorie/mithril.js.git"
|
||||||
--branch "$BRANCH"
|
|
||||||
else
|
else
|
||||||
echo "Not submitting build artifacts"
|
echo "Not submitting documentation updates"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Environment configuration
|
# Environment configuration
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
# Restrict the branch this will activate on
|
|
||||||
- BRANCH=next
|
|
||||||
- REPO=lhorie/mithril.js
|
|
||||||
|
|
||||||
# Set up GH_USER_EMAIL & GH_USER_NAME env variables used by travis-scripts package
|
# Set up GH_USER_EMAIL & GH_USER_NAME env variables used by travis-scripts package
|
||||||
- secure: Xvqvm3+PvJu/rs3jl/NNn0RWLkkLkIoPHiL0GCfVRaywgjCYVN02g54NVvIDaOfybqPmu9E6PJFVs92vhF34NMFQHf4EWskynusIGV271R2BV0i+OJBfLMuLgiwm6zRn7/Zw4JvWIUGEwcnlz0qxbqdHsS0SOR3fIkFzePickW0=
|
- secure: Xvqvm3+PvJu/rs3jl/NNn0RWLkkLkIoPHiL0GCfVRaywgjCYVN02g54NVvIDaOfybqPmu9E6PJFVs92vhF34NMFQHf4EWskynusIGV271R2BV0i+OJBfLMuLgiwm6zRn7/Zw4JvWIUGEwcnlz0qxbqdHsS0SOR3fIkFzePickW0=
|
||||||
- secure: Rf/ldEO9d4vItJhe6EmqWpFAyCARzoCb422nHnjr1hYJknnwIXpgyZ1C/7On/9o7rWPPf+8WcHC/rgjK2rthKCldzdG5I60LfWSNzap9lk3Aa4TpSCoDBuEp7JVvDr5tc3rKnBXVT71hOay7RSx1StWzXiJs9mjaeVMJzYzRT78=
|
- secure: Rf/ldEO9d4vItJhe6EmqWpFAyCARzoCb422nHnjr1hYJknnwIXpgyZ1C/7On/9o7rWPPf+8WcHC/rgjK2rthKCldzdG5I60LfWSNzap9lk3Aa4TpSCoDBuEp7JVvDr5tc3rKnBXVT71hOay7RSx1StWzXiJs9mjaeVMJzYzRT78=
|
||||||
|
|
|
||||||
1
docs/CNAME
Normal file
1
docs/CNAME
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mithril.js.org
|
||||||
|
|
@ -3,13 +3,13 @@ var path = require("path")
|
||||||
var marked = require("marked")
|
var marked = require("marked")
|
||||||
var layout = fs.readFileSync("./docs/layout.html", "utf-8")
|
var layout = fs.readFileSync("./docs/layout.html", "utf-8")
|
||||||
var version = JSON.parse(fs.readFileSync("./package.json", "utf-8")).version
|
var version = JSON.parse(fs.readFileSync("./package.json", "utf-8")).version
|
||||||
try {fs.mkdirSync("../mithril")} catch (e) {}
|
try {fs.mkdirSync("./dist")} catch (e) {}
|
||||||
try {fs.mkdirSync("../mithril/archive")} catch (e) {}
|
try {fs.mkdirSync("./dist/archive")} catch (e) {}
|
||||||
try {fs.mkdirSync("../mithril/archive/v" + version)} catch (e) {}
|
try {fs.mkdirSync("./dist/archive/v" + version)} catch (e) {}
|
||||||
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib")} catch (e) {}
|
try {fs.mkdirSync("./dist/archive/v" + version + "/lib")} catch (e) {}
|
||||||
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib/prism")} catch (e) {}
|
try {fs.mkdirSync("./dist/archive/v" + version + "/lib/prism")} catch (e) {}
|
||||||
try {fs.mkdirSync("../mithril/lib")} catch (e) {}
|
try {fs.mkdirSync("./dist/lib")} catch (e) {}
|
||||||
try {fs.mkdirSync("../mithril/lib/prism")} catch (e) {}
|
try {fs.mkdirSync("./dist/lib/prism")} catch (e) {}
|
||||||
|
|
||||||
var guides = fs.readFileSync("docs/guides.md", "utf-8")
|
var guides = fs.readFileSync("docs/guides.md", "utf-8")
|
||||||
var methods = fs.readFileSync("docs/methods.md", "utf-8")
|
var methods = fs.readFileSync("docs/methods.md", "utf-8")
|
||||||
|
|
@ -55,12 +55,12 @@ function generate(pathname) {
|
||||||
.replace(/<h(.) id="([^"]+?)">(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors
|
.replace(/<h(.) id="([^"]+?)">(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors
|
||||||
return "<h" + n + " id=\"" + text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/<a.*?>.+?<\/a>/g, "").replace(/\.|\[|\]|"|\/|\(|\)/g, "").replace(/\s/g, "-") + "\">" + text + "</h" + n + ">"
|
return "<h" + n + " id=\"" + text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/<a.*?>.+?<\/a>/g, "").replace(/\.|\[|\]|"|\/|\(|\)/g, "").replace(/\s/g, "-") + "\">" + text + "</h" + n + ">"
|
||||||
})
|
})
|
||||||
fs.writeFileSync("../mithril/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
fs.writeFileSync("./dist/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||||
fs.writeFileSync("../mithril/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
fs.writeFileSync("./dist/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||||
}
|
}
|
||||||
else if (!pathname.match(/lint|generate/)) {
|
else if (!pathname.match(/lint|generate/)) {
|
||||||
fs.writeFileSync("../mithril/archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
fs.writeFileSync("./dist/archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
||||||
fs.writeFileSync("../mithril/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
fs.writeFileSync("./dist/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue