forked from nus-cs2103-AY1819S1/addressbook-level1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Our markdown documentation is published to GitHub pages via its automatic markdown files publishing support[1]. However, this mechanism does not support asciidoc files. We are in the process of converting all of our documentation to asciidoc, so we'll need to setup our own GitHub pages build and deployment system. Let's reuse the asciidoc-to-html build system in addressbook-level4[2] by copying the relevant code/files. [1] https://github.com/blog/2289-publishing-with-github-pages-now-as-easy-as-1-2-3 [2] https://github.com/se-edu/addressbook-level4
- Loading branch information
Showing
6 changed files
with
532 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ test/data/ | |
|
||
# Gradle files | ||
/.gradle/ | ||
/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
language: java | ||
matrix: | ||
include: | ||
- jdk: oraclejdk9 | ||
|
||
script: >- | ||
./gradlew | ||
deploy: | ||
skip_cleanup: true | ||
provider: script | ||
script: ./config/travis/deploy_github_pages.sh | ||
on: | ||
branch: master | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- oracle-java9-installer | ||
|
||
before_cache: | ||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | ||
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/ | ||
|
||
cache: | ||
directories: | ||
- $HOME/.gradle/caches/ | ||
- $HOME/.gradle/wrapper/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Gradle Configuration File | ||
// For more details take a look at the Java Quickstart chapter in the Gradle | ||
// user guide available at http://gradle.org/docs/4.8.1/userguide/tutorial_java_projects.html | ||
|
||
plugins { | ||
id 'org.asciidoctor.convert' version '1.5.6' | ||
} | ||
|
||
asciidoctor { | ||
backends 'html5' | ||
sourceDir 'docs' | ||
outputDir "${buildDir}/docs" | ||
|
||
attributes = [ | ||
linkcss: true, | ||
stylesheet: 'gh-pages.css', | ||
'source-highlighter': 'coderay', | ||
icons: 'font', | ||
experimental: true, | ||
sectlinks: true, | ||
idprefix: '', // for compatibility with GitHub preview | ||
idseparator: '-', | ||
] | ||
} | ||
|
||
// Copies stylesheets into the directory containing generated HTML files as | ||
// Asciidoctor does not copy linked CSS files to the output directory when rendering. | ||
// This is needed for linked stylesheets and embedded stylesheets which import other files. | ||
task copyStylesheets(type: Copy) { | ||
from "${asciidoctor.sourceDir}/stylesheets" | ||
into "${asciidoctor.outputDir}/html5/stylesheets" | ||
} | ||
asciidoctor.dependsOn copyStylesheets | ||
|
||
defaultTasks 'clean', 'asciidoctor' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/sh | ||
# Pushes files generated by Asciidoctor and associated files to gh-pages branch for commits to master branch. | ||
|
||
set -o errexit # exit with nonzero exit code if any line fails | ||
|
||
if [ -z "$GITHUB_TOKEN" ]; then | ||
echo 'GITHUB_TOKEN is not set up in Travis. Skipping deploy.' | ||
exit 0 | ||
fi; | ||
|
||
set -o nounset # exit if variable is unset | ||
|
||
cd build/docs/html5 | ||
|
||
git init | ||
git config user.name 'Deployment Bot (Travis)' | ||
git config user.email '[email protected]' | ||
|
||
git config credential.helper 'store --file=.git/credentials' | ||
echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials | ||
|
||
git remote add upstream "https://github.com/${TRAVIS_REPO_SLUG}.git" | ||
|
||
# Reset to gh-pages branch, or create orphan branch if gh-pages does not exist in remote. | ||
if git ls-remote --exit-code --heads upstream gh-pages; then | ||
git fetch --depth=1 upstream gh-pages | ||
git reset upstream/gh-pages | ||
elif [ $? -eq 2 ]; then # exit code of git ls-remote is 2 if branch does not exist | ||
git checkout --orphan gh-pages | ||
else # error occurred | ||
exit $? | ||
fi | ||
|
||
# Exit if there are no changes to gh-pages files. | ||
if changes=$(git status --porcelain) && [ -z "$changes" ]; then | ||
echo 'No changes to GitHub Pages files; exiting.' | ||
exit 0 | ||
fi | ||
|
||
git add -A . | ||
git commit -m "Rebuild pages at ${TRAVIS_COMMIT}" | ||
git push --quiet upstream HEAD:gh-pages |
Oops, something went wrong.