Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (82 sloc) 2.06 KB
version: 2.1
executors:
python36:
docker:
- image: circleci/python:3.6
working_directory: ~/repo
jobs:
fetch_csv:
executor: python36
steps:
- checkout:
path: ~/repo
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
- run:
name: Install dependencies
command: |
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}
- run:
name: Build CSV
command: |
. venv/bin/activate
python main.py
- persist_to_workspace:
root: .
paths:
- tweets.csv
push_csv:
executor: python36
steps:
- checkout:
path: ~/repo
- attach_workspace:
at: /tmp
- add_ssh_keys:
fingerprints:
- "3f:fd:39:1e:7d:5d:45:bb:1c:0f:df:fe:f6:91:6e:05"
- run:
name: Set Git identity
command: |
git config --global user.email "robot@circleci.com"
git config --global user.name "CircleCI"
- run:
name: Push to GitHub
command: |
git clone git@github.com:AntoineAugusti/tweets-rerb.git /tmp/tweets-rerb
cp /tmp/tweets.csv /tmp/tweets-rerb/tweets.csv
cd /tmp/tweets-rerb/
if [ -n "$(git status --porcelain)" ]; then
git commit -am "New tweets at $(date -u +'%Y-%m-%dT%H:%M:%SZ') [skip ci]"
git push origin master
else
echo "No changes";
fi
workflows:
version: 2
fetch_and_push:
jobs:
- fetch_csv
- push_csv:
requires:
- fetch_csv
cron:
triggers:
- schedule:
cron: "0 * * * *"
filters:
branches:
only:
- master
jobs:
- fetch_csv
- push_csv:
requires:
- fetch_csv