From 09d6b1bbc661782289152f2b6e976377bc0a5bfc Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Sun, 15 Sep 2019 12:03:50 -0700 Subject: [PATCH] add circleCI config --- .circleci/config.yml | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..74557d4 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,45 @@ +version: 2 +jobs: + build: + docker: + - image: cibuilds/hugo:0.57 + working_directory: ~/project + environment: + BRANCH: master + TARGET_REPO: MoonsideGames/ + steps: + - checkout + - run: + name: "Run Hugo" + command: HUGO_ENV=production hugo -v -s ~/project/src + - deploy: + command: | + if [ "${CIRCLE_BRANCH}" = "master" ]; then + echo -e "Starting to deploy to Github Pages\n" + mkdir ~/repo + cd ~/repo + git config --global user.email "builds@circleci.com" + git config --global user.name "CircleCI" + #using token clone gh-pages branch + git clone --quiet --branch=$CIRCLE_BRANCH https://${GH_TOKEN}@github.com/$TARGET_REPO built_website > /dev/null + # Installing rsync + echo "Installing rsync" + sudo apt-get -y install rsync + #go into directory and copy data we're interested in to that directory + cd built_website + echo "rsync built code with checked out code..." + rsync -r --exclude=.git --delete ~/project/src/build ~/repo + #add, commit and push files + echo "add files to git..." + git add -f . + echo "commit files to git repository..." + if git commit -m "CircleCI build $CIRCLE_BUILD_NUM pushed to Github Pages" ; then + echo "git push files with force..." + git push -fq origin $BRANCH > /dev/null + echo -e "Deploy completed\n" + else + echo "Content not changed, nothing to deploy" + fi + else + echo "Not master branch, dry run only" + fi