Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

heroku CLI auth by token

Every time after building and pushing docker image from Gitlab registry to Heroku registry I need to execute heroku container:release web to Heroku run image (release), but I wanna automate this

I added heroku CLI tool installation into gitlab-ci-yml, but I can't auth heroku CLI by token
When I try to set HEROKU_API_KEY=token and run heroku login I get an error Error: Cannot log in with HEROKU_API_KEY set
Also tried to do this with HEROKU_DEBUG on, but debugger info couldn't help me
I can't use ~/.netrc

Any way to auth heroku CLI or automate releasing docker images in heroku?

current gitlab-ci.yml:

before_script:
    - apt install snapd
    - snap install --classic heroku
    - HEROKU_API_KEY=$HEROKU_API_TOKEN heroku login
    - docker login -u $REGISTRY_UNAME -p $REGISTRY_PWD registry.gitlab.com
    - docker login --username=_ --password=$HEROKU_PWD registry.heroku.com
script:
    # a lot of tag & push lines
    - heroku container:release web
like image 358
sula Avatar asked Jul 22 '26 04:07

sula


1 Answers

If you have set the HEROKU_API_KEY environment variable, you don't have to log in again. The API key will be used for the Heroku CLI commands if present.

Make sure to use heroku authorizations:create to create never-expiring tokens. Check this out for a detailed explanation.

Ref: https://github.com/heroku/cli/issues/502#issuecomment-309099883

Note that the git commands like git push heroku master won't use the API key. See this for more info.

like image 159
Arun Kumar Mohan Avatar answered Jul 24 '26 19:07

Arun Kumar Mohan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!