As the title says, when I push to stage, I expect the latest commits from my stage branch to appear in my stage app on Heroku. The build triggers a deployment to Heroku, but it’s pushing my master branch, not my stage branch. FWIW, this config file used to work as expected. Not sure what happened.
See config.yml below:
workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
build-deploy-stage:
jobs:
- build
- deploy-stage:
requires:
- build
filters:
branches:
only: stage
version: 2
jobs:
build:
working_directory: ~/doc-uploader
docker:
- image: circleci/ruby:2.6.3-node-browsers
environment:
PGHOST: localhost
PGUSER: doc-uploader
RAILS_ENV: test
- image: postgres:9.6
environment:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_USER: doc-uploader
POSTGRES_DB: doc-uploader_test
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: install dependencies
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
- run:
name: Database setup
command: bundle exec rake db:setup
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:5432 -timeout 1m
# Run Tests
- run:
name: run tests
command: |
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
bundle exec rspec --format progress \
--out /tmp/test-results/rspec.xml \
--format progress \
$TEST_FILES
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
deploy:
docker:
- image: buildpack-deps:trusty
working_directory: ~/doc-uploader
steps:
- checkout
- run:
name: Deploy Master to Heroku
command: |
git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git
deploy-stage:
docker:
- image: buildpack-deps:trusty
working_directory: ~/doc-uploader
steps:
- checkout
- run:
name: Deploy Stage to Heroku
command: |
git push --force https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_STAGE_APP_NAME.git