version: 2 jobs: build: machine: true working_directory: ~/repo steps: - checkout - run: name: Check if Packer files were modified command: | export COMMIT_ID="$(echo $CIRCLE_COMPARE_URL | cut -d '/' -f 7)" if [ "$(git diff-tree --no-commit-id --name-only -r $COMMIT_ID | grep -c \"^Packer/\")" -gt 0 ]; then export PACKER_MODIFIED=1 else export PACKER_MODIFIED=0 fi - run: name: Check if Vagrant files were modified command: | export COMMIT_ID="$(echo $CIRCLE_COMPARE_URL | cut -d '/' -f 7)" if [ "$(git diff-tree --no-commit-id --name-only -r $COMMIT_ID | grep -c \"^Vagrant/\")" -gt 0 ]; then export VAGRANT_MODIFIED=1 else export VAGRANT_MODIFIED=0 fi - run: name: Choose which build gets run command: | if [[ "$PACKER_MODIFIED" -eq 1 ]] && [[ "$VAGRANT_MODIFIED" -eq 1 ]]; then chmod +x ci/circle_workflows/packer_and_vagrant_changes.sh ci/circle_workflows/packer_and_vagrant_changes.sh exit 0 fi if [[ "$PACKER_MODIFIED" -eq 1 ]] && [[ "$VAGRANT_MODIFIED" -eq 1 ]]; then chmod +x ci/circle_workflows/vagrant_changes.sh ci/circle_workflows/vagrant_changes.sh exit 0 fi if [ "$PACKER_MODIFIED" -eq 1 ]; then chmod +x ci/circle_workflows/packer_changes.sh ci/circle_workflows/packer_changes.sh exit 0 fi if [ "$VAGRANT_MODIFIED" -eq 1 ]; then chmod +x ci/circle_workflows/vagrant_changes.sh ci/circle_workflows/vagrant_changes.sh exit 0 fi - store_artifacts: path: /tmp/artifacts