Skip to content
Permalink
Browse files

Cron job to sync from Strava.

  • Loading branch information...
dblock committed Feb 16, 2018
1 parent 1927f12 commit 2a08d5ec0b97a49003ccf8f69c467d7a693ad2a2
Showing with 47 additions and 0 deletions.
  1. +11 −0 .travis.yml
  2. +11 −0 CRON.md
  3. +25 −0 _scripts/update.sh
@@ -0,0 +1,11 @@
language: ruby

rvm:
- 2.4.1

script:
- bash ./_scripts/update.sh

branches:
only:
- gh-pages
11 CRON.md
@@ -0,0 +1,11 @@
# Travis CI Cron

This project uses a Travis CI cronjob to automatically sync with Strava once a day.

## Strava Token

Create an app and obtain a public token from [strava.com/settings/api](https://www.strava.com/settings/api). Set it as `STRAVA_API_TOKEN` in Travis-CI.

## Github Token

To commit to Github you need a `public_repo` permission token. Create one in [github.com/settings/tokens](https://github.com/settings/tokens). Set it as `GH_TOKEN` in Travis-CI.
@@ -0,0 +1,25 @@
#!/bin/bash

set -e
set -o pipefail

bundle exec rake strava:update

gh_token="${GH_TOKEN-}"

if [ -z "$gh_token" ]
then
echo "GH_TOKEN is not set. Cannot proceed." >&2
exit 1
fi

git config --global user.name "Run Buildbot"
git config --global user.email "dblock+run@dblock.org"
git add .
if ! git diff --quiet --staged
then
git commit -m "Updated from Strava, `date +%Y/%m/%d`."
git push "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" HEAD:gh-pages
else
echo "Nothing has changed! I hope that's what you expected." >&2
fi

0 comments on commit 2a08d5e

Please sign in to comment.
You can’t perform that action at this time.