Git Push Fails When Trying to Tag release

git

#1

I’m getting the following error when trying to push a tag from circleci back to GitHub. I see the obvious answer in the error itself, but I’m wondering if there is a best-practice for CircleCI to manage this automatically?

Error: Command failed: git push && git push --tags
fatal: The current branch feature/typescript has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin feature/typescript


    at ChildProcess.exithandler (child_process.js:207:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:852:16)
    at Socket.<anonymous> (internal/child_process.js:323:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:492:12)

#2

Why I try and set the upstream branch, I get this error:

git push --set-upstream origin ${CIRCLE_BRANCH}
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

git push --set-upstream origin ${CIRCLE_BRANCH} returned exit code 128

Action failed: git push --set-upstream origin ${CIRCLE_BRANCH}

#3

It looks like I’m having a conversation with myself, but hopefully this will be useful to others in the future.

I solved this problem by adding the following to my deployment section in circle.yml:

      - git push --set-upstream origin ${CIRCLE_BRANCH}
      - git config --global user.email "swdev@6river.com"
      - git config --global user.name "CircleCI"

Also, make sure you add [skip ci] to your commit message, or CircleCI will build your new commit too, which might not be what you want.


#4

One last update to this - if this commit is part of a pull request, and you have protected branches enabled on Git Hub, the PR will be hung up waiting for the newly tagged commit to finish CI, which you just configured not to run.

To get around the deadlock, you will need to break you deployment section out into a shell script and add a feature to [skip deploy], so that the build will still run but deployment is skipped. This way GitHub sees the build completes successfully, but you avoid a continuous feedback loop where CircleCI is generating commits and triggering builds on its own commits.


#5

Hey @jbcpollak!

You’re having a conversation with me now also B-)

I was able to push to origin by following this advice: https://circleci.com/docs/github-security-ssh-keys/

As to the chicken-and-egg problem with protected branches, PRs and auto-building - I’m having that same issue myself right now. Could you please elaborate on what to do with the [skip-deploy] in this scenario?


#6