Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
70 lines (64 sloc) 2.43 KB
version: 2
jobs:
build:
docker:
- image: circleci/python:3.7.1
working_directory: ~/repo
environment:
BRANCH: master
TARGET_REPO: andreagrandi/andreagrandi.github.io.git
PELICAN_OUTPUT_FOLDER: output
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- run:
name: build static pages with Pelican
command: |
. venv/bin/activate
pelican content -o output -s publishconf.py
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}
- deploy:
name: Deploy static pages to Github Pages
command: |
if [ "${CIRCLE_BRANCH}" = "master" ]; then
echo -e "Starting to deploy to Github Pages\n"
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 ../$PELICAN_OUTPUT_FOLDER/ ./
#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
You can’t perform that action at this time.