forked from GSA/code-gov-github-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
79 lines (74 loc) · 2.9 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
version: 2
jobs:
build:
docker:
- image: circleci/python:3.8.1
working_directory: ~/repo
environment:
BRANCH: master
TARGET_REPO: github.com/saikrishnabairamoni.github.io
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 "[email protected]"
git config --global user.name "CircleCI"
#using token clone gh-pages branch
git clone --quiet --branch=$CIRCLE_BRANCH https://${ghp_UFSYtdn5nJldinSaLElL6kjvEuNq0qIDEkF}@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
- run:
name: Purge Cloudflare cache
command: |
if [ "${CIRCLE_BRANCH}" = "master" ]; then
curl -X POST "https://api.cloudflare.com/client/v4/zones/$CF_ZONE_ID/purge_cache" \
-H "X-Auth-Email: $CF_AUTH_EMAIL" \
-H "X-Auth-Key: $CF_AUTH_KEY" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
fi