We have two jobs in our workflow, build
and deploy
. We have three “main” branches, develop
, staging
and deploy
. We have it configured to build when the PR is submitted and then build + deploy when the PR is merged. This works completely as intended on develop
(which does happen to be our default branch, not sure if related) but on staging
it’s doing build and deploy whent he PR has been submitted AND when it’s merged which definitely isn’t what we want. I’m guessing this is just an option I’ve missed somewhere, but below are some details:
Build Settings from CircleCI:
Our config.yml for CircleCI:
version: 2
jobs:
build:
docker:
- image: circleci/php:7.1-node-browsers
- image: circleci/mysql:5.7.21
environment:
MYSQL_DATABASE: homestead_test
MYSQL_USER: homestead_test
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: root
working_directory: ~/laravel
steps:
- checkout
- run:
name: Install dockerize
command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
environment:
DOCKERIZE_VERSION: v0.6.1
- run:
name: Wait for MySQL
command: dockerize -wait tcp://localhost:3306 -timeout 1m
- run:
name: Install PHP extensions
command: sudo docker-php-ext-install pdo_mysql
- run: chmod -R 777 storage
- run: cp .env.testing.example .env
# Download and cache dependencies
# Composer
- restore_cache:
name: Restore composer cache
keys:
- composer-{{ checksum "composer.json" }}
- composer-
- run: composer install -n --prefer-dist
- save_cache:
name: Store composer cache
key: composer-{{ checksum "composer.json" }}
paths:
- vendor
- run: php artisan migrate --database=mysql_test
- run: vendor/bin/phpunit
deploy:
working_directory: ~/laravel
docker:
- image: circleci/php:7.1-node-browsers
steps:
- checkout
- run:
name: Installing deployment dependencies
working_directory: /
command: |
sudo apt-get -y -qq update
sudo apt-get install python-pip python-dev build-essential
sudo pip install awsebcli --upgrade
- run:
name: Initializing AWS config
command: sh ./.circleci/setup-eb.sh
- run:
name: Deploying
command: eb deploy --timeout 60
workflows:
version: 2
build_deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only:
- develop
- staging
- master
notify:
webhooks:
- url: https://tools.xxxxxx.com/webhooks/circleci/