Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Deployment with tags #7

Closed
campbecf opened this issue Jun 16, 2020 · 1 comment
Closed

Deployment with tags #7

campbecf opened this issue Jun 16, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@campbecf
Copy link
Contributor

Orb Version
1.0.1

Describe the bug

When using a tag to trigger a deployment the deploy-via-git command fails with the following message:

#!/bin/bash -eo pipefail
if false;then
  force="-f"
fi
git push $force https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git $CIRCLE_BRANCH:master
remote: 
remote: !	Push rejected, cannot delete master branch        
remote: 
To https://git.heroku.com/example.git
 ! [remote rejected]     master (pre-receive hook declined)
error: failed to push some refs to 'https://heroku:************************************@git.heroku.com/example.git'
Exited with code exit status 1
CircleCI received exit code 1

To Reproduce

Trigger a deployment via a tag.

Expected behavior

Should deploy the tag.

Additional context

I believe this has to do with the CIRCLE_TAG variable being set but not CIRCLE_BRANCH ?

@a14m
Copy link
Contributor

a14m commented Jul 27, 2020

there are 2 problems causing this to fail,
the first one is CIRCLE_BRANCH has empty value (when CIRCLE_TAG has it)...
The second problem (more importantly), there will be miss-matching references... changing the value of the parameters.branch to eq $CIRCLE_TAG or even $CIRCLE_TAG^{} isn't guaranteed to work...
because the :master part on heroku will try to infer what is the pushed reference... and since it will find the <src> reference is a tag, it'll try to create the tag on <dest> which will succeed but won't trigger any deployment
(Ref: https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-push.html check <refspec> docs)

Writing objects: 100% (2058/2058), 1.54 MiB | 882.00 KiB/s, done.
Total 2058 (delta 1189), reused 280 (delta 143), pack-reused 0
remote: Pushed to branch other than [main, master], skipping build.
To https://git.heroku.com/XXXXXXXXXXXX.git
 * [new tag]         v2.0.0 -> main

(it creates a tag on heroku remote called main, not pushing to the heroku branch, denoted by * [new tag] in logs)

for this to work, the <dest> has always to be refs/heads/master (or refs/heads/main) otherwise it'll be ignored by heroku
Ref: https://devcenter.heroku.com/articles/git#deploying-code

@gmemstr gmemstr closed this as completed Sep 16, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants