Build filters Question

we have three branches: master, staging, and develop. we use feature/ to build out new features. What we want is for any PR to kick off a build and a test flow. This is easy with PR only option selected.

HOWEVER

We also want the system to build and deploy after the PR is reviewed and accepted. So when the merge to dev, staging or prod happens with the PR accepted we need the system to fire a separate workflow or use filters to achieve this.

From what I can tell, this may not be possible with CircleCI as it currently stands. Is there something that we are missing that could help here?

Basically, we don’t want anything to fire on the feature branches until the PR, but also need the deploy to fire after the PR is accepted which doesnt happen now. Thanks in advance.

My first post on here, so be gentle :wink:
One thing you could do (it is what I do for projects) is to turn off PR only.
Use filters:branches:only for the master/staging/develop branches (i.e a merge is ongoing).
Use a branches:ignore for master/staging/develop, and check $CIRCLE_PULL_REQUEST to indicate that this is a PR from another branch.

if [ -z "$CIRCLE_PULL_REQUEST" ]; then
    echo 'do something cool with this PR'
fi

As far as I know, what your are asking for does not have an out-of-the-box solution.
Also, I don’t think the target branch is available - but you could add some magic string (like [skip ci]) to the commit message and get it with echo "export COMMIT_MESSAGE=\"$(git log --format=oneline -n 1 $CIRCLE_SHA1)\"" >> ~/.bashrc

Thanks for the post. This was my first on this board as well :slight_smile:

I was trying to avoid using script logic to kick things off, but if no one else chimes in I may be forced to. I am going to try and test out some more filters, but thanks again for the response. It would be really nice if circle put the PR only on a branch basis, rather than a repo basis