Create PR upon successful build

github
circle.yml

#1

I’m trying to send an API call to GitHub to create a PR if a branch starting with feature/ is successful.

deployment:
  feature:
    branch: /feature\/.*/
    commands:
      - curl -X POST -H "Authorization: 'token $GITHUB_TOKEN'" -d "{'base':'master','head':'$CIRCLE_BRANCH','title':'Merge with $CIRCLE_BRANCH'}" https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls

I have tried a bunch of variations of this, but always getting less than straightforward error messages from the circle.yml parser. Is there something I’m clearly doing wrong?

Note: the build fails, not the API call.


#2

Hello,

First, we will only run deployment if the build passes.

Secondly, please be sure the branch matches your PR branch, you should see the command show up in the “deploy” phase of the build summary.

Also, are you able to create a PR using this curl outside of CI?


#3