Skip to content

Commit feb2079

Browse files
authored
Merge pull request #15 from ArthurHoaro/deploy-gh-pages
Deploy gh pages
2 parents f787212 + 55449c6 commit feb2079

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: node_js
2+
node_js:
3+
- stable
4+
addons:
5+
apt:
6+
sources:
7+
- ubuntu-toolchain-r-test
8+
packages:
9+
- gcc-5
10+
- g++-5
11+
12+
before_script:
13+
- npm install -g aglio
14+
script:
15+
- bash ./deploy.sh
16+
env:
17+
global:
18+
- ENCRYPTION_LABEL: "91dc7b3864c4"
19+
- COMMIT_AUTHOR_EMAIL: "shaarli@hoa.ro"
20+
- CC: "gcc-5"
21+
- CXX: "g++-5"
22+
- LINK: "gcc-5"
23+
- LINKXX: "g++-5"
24+
25+

deploy.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
set -e # Exit with nonzero exit code if anything fails
3+
4+
# Source: https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
5+
6+
SOURCE_BRANCH="master"
7+
TARGET_BRANCH="gh-pages"
8+
9+
function doCompile {
10+
aglio -i api-documentation.md -o out/index.html
11+
}
12+
13+
# Pull requests and commits to other branches shouldn't try to deploy
14+
# if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
15+
# echo "Skipping deploy."
16+
# exit 0
17+
# fi
18+
19+
# Save some useful information
20+
REPO=`git config remote.origin.url`
21+
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
22+
SHA=`git rev-parse --verify HEAD`
23+
24+
# Clone the existing gh-pages for this repo into out/
25+
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
26+
git clone $REPO out
27+
cd out
28+
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
29+
cd ..
30+
31+
# Clean out existing contents
32+
rm -rf out/* || exit 0
33+
34+
# Run our compile script
35+
doCompile
36+
37+
# Now let's go have some fun with the cloned repo
38+
cd out
39+
git config user.name "Travis CI"
40+
git config user.email "$COMMIT_AUTHOR_EMAIL"
41+
42+
# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
43+
if [ -z `git diff --exit-code` ]; then
44+
echo "No changes to the output on this push; exiting."
45+
exit 0
46+
fi
47+
48+
# Commit the "changes", i.e. the new version.
49+
# The delta will show diffs between new and old versions.
50+
git add index.html
51+
git commit -m "Deploy to GitHub Pages: ${SHA}"
52+
53+
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
54+
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
55+
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
56+
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
57+
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
58+
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in ../shaarli.enc -out deploy_key -d
59+
chmod 600 deploy_key
60+
eval `ssh-agent -s`
61+
ssh-add deploy_key
62+
63+
# Now that we're all set up, we can push.
64+
git push $SSH_REPO $TARGET_BRANCH

shaarli.enc

3.17 KB
Binary file not shown.

0 commit comments

Comments
 (0)