Skip to content

Commit

Permalink
Split the build script from the publication on Travis
Browse files Browse the repository at this point in the history
This allows running the publication only for branch pushes and not for
pull requests.
The creation of the orphan commit for the master branch with the built
website has been refactored to avoid having to filtering the branch each
time, which is faster.
The new script also avoids changing the git email and username globally,
making it much safer to run the publish task locally (through bldr for
instance).
  • Loading branch information
stof committed Feb 18, 2015
1 parent ecfa689 commit 84841fd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ before_script:
- composer install --prefer-dist

script:
- sh publish.sh
- sh build.sh

after_success:
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sh publish.sh; fi

env:
global:
Expand Down
10 changes: 10 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh
# make the script fail for any failed command
set -e
# make the script display the commands it runs to help debugging failures
set -x

# build site
sass source/css/wouterj.scss:source/css/wouterj.css --style compressed --no-cache
./vendor/bin/sculpin generate --env prod
touch output_prod/.nojekyll
28 changes: 13 additions & 15 deletions publish.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
#!/usr/bin/env sh
# make the script fail for any failed command
set -e
# make the script display the commands it runs to help debugging failures
set -x

# configure env
git config --global user.email '[email protected]'
git config --global user.name 'WouterJ.nl bot'
# Go to the output directory
cd output_prod

# checkout publish branch
if [ "`git show-ref --heads master`" ]; then
git branch -D master
# Remove the existing repo if it exists
if [ -d ".git" ]; then
rm -rf .git
fi
git checkout -b master

# build site
sass source/css/wouterj.scss:source/css/wouterj.css --style compressed --no-cache
./vendor/bin/sculpin generate --env prod
touch output_prod/.nojekyll
# Create a repo for the built website for the master branch
git init

# configure env (locally)
git config user.email '[email protected]'
git config user.name 'WouterJ.nl bot'

# commit build
git add -f output_prod
git add .
git commit -m "Build website"

# only push output
git filter-branch --subdirectory-filter output_prod/ -f

# push to GitHub Pages
git push "https://github.com/WouterJ/wouterj.github.com" -f master

0 comments on commit 84841fd

Please sign in to comment.