Skip to content

Commit

Permalink
🔧 Try auto-deploy with CircleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
june29 committed Jan 23, 2017
1 parent 13ccb8e commit 1d3bc5f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
21 changes: 21 additions & 0 deletions circle.yml
@@ -0,0 +1,21 @@
checkout:
post:
- git submodule sync
- git submodule update --init --recursive

machine:
timezone: Asia/Tokyo

dependencies:
pre:
- go get -v github.com/spf13/hugo

test:
override:
- "true"

deployment:
production:
branch: master
commands:
- ./scripts/push-to-gh-pages.sh
37 changes: 37 additions & 0 deletions scripts/push-to-gh-pages.sh
@@ -0,0 +1,37 @@
#!/bin/bash -eux

if [ -z "${GIT_USER_NAME}" ]; then
echo "Please set an env var GIT_USER_NAME"
exit 1
fi

if [ -z "${GIT_USER_EMAIL}" ]; then
echo "Please set an env var GIT_USER_EMAIL"
exit 1
fi

GIT_REPO="git@github.com:${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git"

git submodule init
git submodule update

remote=`git ls-remote --heads 2> /dev/null | grep gh-pages || true`

if [ -n "$remote" ]; then
git clone -b gh-pages "${GIT_REPO}" public
rm -rf public/*
else
git init public
cd public
git checkout -b gh-pages
git remote add origin "${GIT_REPO}"
cd ..
fi

hugo
cd public
git config --global user.name "${GIT_USER_NAME}"
git config --global user.email "${GIT_USER_EMAIL}"
git add --all
git commit -m '[ci skip]'
git push -f origin gh-pages

0 comments on commit 1d3bc5f

Please sign in to comment.