Skip to content

Instantly share code, notes, and snippets.

@therebelrobot
Last active December 12, 2018 22:37
Show Gist options
  • Save therebelrobot/61a2b3afd15bbc4d2fbbecd8c3ea8230 to your computer and use it in GitHub Desktop.
Save therebelrobot/61a2b3afd15bbc4d2fbbecd8c3ea8230 to your computer and use it in GitHub Desktop.
CircleCI Repeated Cron Job
# change defaults:docker:image for a different docker image
# change jobs:checkout:steps:restore_cache:keys and :save_cache:key to the file needed for checksum
# change jobs:checkout:steps:run to whatever is needed for dep installation
# change jobs:checkout:steps:save_cache:paths to the paths you'd like to cache between runs
# change task:steps:run:command to the bash command to run
# change workflows:repeated:triggers:schedule:cron to the appropriate cron syntax
# cron reference: https://www.unix.com/man-page/POSIX/1posix/crontab/
# cron recipes: https://alvinalexander.com/linux/unix-linux-crontab-every-minute-hour-day-syntax
defaults: &defaults
docker:
- image: circleci/node:8.11-jessie-browsers
working_directory: ~/tmp/circlci-now
version: 2
jobs:
checkout:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/tmp/circlci-now
- restore_cache:
keys:
- npm-cache-{{ .Branch }}-{{ checksum "package.json" }}
- npm-cache-{{ .Branch }}
- npm-cache-
- run:
name: Dependency Install
command: yarn
- save_cache:
key: npm-cache-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- node_modules
- persist_to_workspace:
root: .
paths: .
task:
<<: *defaults
steps:
- attach_workspace:
at: ~/tmp/circlci-now
- run:
name: Run Coverage
command: |
./run-script.sh
workflows:
version: 2
repeated:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs:
- task
requires:
- checkout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment