version: 2
jobs:
linter:
docker:
- image: nlknguyen/alpine-shellcheck:v0.4.6
steps:
- checkout
- run:
name: Check scripts
command: |
shellcheck --external-sources check_new_release
update_tap_on_new_build:
docker:
- image: circleci/python:2.7
steps:
- checkout
- restore_cache:
keys:
- build-date-
- run:
name: Check for new build and update tap
command: |
echo "Last build date check before: $(cat .last_build_date)"
export DEBUG=y
./check_new_release -v
unset DEBUG
if [[ $(git status -s | grep -c 'M vke-cli.rb') == 1 ]]; then
pip install awscli --upgrade --user
~/.local/bin/aws --output json --region us-east-1 \
ses send-email \
--from alister@lewis-bowen.org \
--to alister@different.com \
--subject "[CircleCI] New build found for vke" \
--text "automated email from build script"
git config credential.helper 'cache --timeout=120'
git config user.email "alister@lewis-bowen.org"
git config user.name "CircleCI deployment job"
git add vke-cli.rb && \
git commit -m'Update tap for new build' && \
git push -q https://${GITHUB_PERSONAL_TOKEN}@github.com/ali5ter/homebrew-vke-cli.git master
fi
echo "Last build date check after: $(cat .last_build_date)"
- save_cache:
key: build-date-{{ checksum ".last_build_date" }}
paths:
.last_build_date
build_completion_script:
docker:
- image: circleci/python:2.7
steps:
- run:
name: Clone completion script repo
working_directory: ${CIRCLE_WORKING_DIRECTORY}
command: |
git clone https://${GITHUB_PERSONAL_TOKEN}@github.com/ali5ter/vke-completion.git
- deploy:
name: Create completion script and commit if there are changes
working_directory: ${CIRCLE_WORKING_DIRECTORY}/vke-completion
command: |
git pull
./create_completion
if [[ $(git status -s | grep -c 'M vke_bash_completion.sh') == 1 ]]; then
git config credential.helper 'cache --timeout=120'
git config user.email "alister@lewis-bowen.org"
git config user.name "CircleCI deployment job"
git add vke_bash_completion.sh && \
git commit -m'Update completion for new CLI build' && \
git push -q https://${GITHUB_PERSONAL_TOKEN}@github.com/ali5ter/vke-completion.git master
fi
create_taxo_graph:
docker:
- image: circleci/python:2.7
steps:
- run:
name: Clone completion script repo
working_directory: ${CIRCLE_WORKING_DIRECTORY}
command: |
git clone https://${GITHUB_PERSONAL_TOKEN}@github.com/ali5ter/vke-completion.git
- deploy:
name: Create taxo graph and commit if there are changes
working_directory: ${CIRCLE_WORKING_DIRECTORY}/vke-completion
command: |
git pull
./create_taxo_graph
if [[ $(git status -s | grep -c 'M taxonomy/data.csv') == 1 ]]; then
git config credential.helper 'cache --timeout=120'
git config user.email "alister@lewis-bowen.org"
git config user.name "CircleCI deployment job"
git add taxonomy/data.csv && \
git commit -m'Update taxo graph for new CLI build' && \
git push -q https://${GITHUB_PERSONAL_TOKEN}@github.com/ali5ter/vke-completion.git master
fi
workflows:
version: 2
commit-workflow:
jobs:
- linter
schedule-workflow:
triggers:
- schedule:
cron: "0,30 * * * *"
filters:
branches:
only: master
jobs:
- update_tap_on_new_build
- build_completion_script:
requires:
- update_tap_on_new_build
- create_taxo_graph:
requires:
- update_tap_on_new_build