Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add Instructions On How To Authenticate In A Deploy Step #8

Open
alexfinnarn opened this issue Sep 10, 2020 · 2 comments
Open

Add Instructions On How To Authenticate In A Deploy Step #8

alexfinnarn opened this issue Sep 10, 2020 · 2 comments

Comments

@alexfinnarn
Copy link

I'm trying to run a release script to copy a database from a staging environment to a review app.

  # In release script...
  heroku config:set HEROKU_API_KEY=`heroku auth:token`
  heroku pg:copy stage-app-name::$DATABASE_URL $DATABASE_URL -a $HEROKU_APP_NAME --confirm $HEROKU_APP_NAME

But I get authentication errors.

 ›   Error: not logged in
 ›   Error: Missing required flag:
 ›     -a, --app APP  app to run command against
 ›   See more help with --help
 ▸    Invalid credentials provided.
heroku: Press any key to open up the browser to login or q to exit:  ▸    Invalid credentials provided.
Enter your Heroku credentials:
Email: 

So, I'm trying to figure out how to login the best way in a review app environment in order to use the CLI commands during the release phase. Is the recommended way to use a permanemtn machine user? Or to do it in a more ephemeral way each release?

I think I can add a user, store creds in environmental variables, and then use those to login, but I'm not sure of the best option. I figure plenty of other people want to do this or have accomplished it already.

@rlueder
Copy link

rlueder commented Nov 11, 2020

After spending more time on this than I'm willing to admit I eventually got it working by directly setting HEROKU_API_KEY under my pipeline settings (see attached)

image

On your local terminal (assuming you have already logged into the CLI app with your username/password) run: heroku authorizations:create --short this will create a long-lived token you can use to set HEROKU_API_KEY

You'll also want to wrap your command inside of heroku run e.g.
heroku run "heroku pg:copy stage-app-name::$DATABASE_URL $DATABASE_URL -a $HEROKU_APP_NAME --confirm $HEROKU_APP_NAME" -a $HEROKU_APP_NAME

@alexfinnarn
Copy link
Author

alexfinnarn commented Nov 11, 2020

Thanks @rlueder for the explanation. I can also say I ended up using this method of directly setting HEROKU_API_KEY config var in the pipeline settings and it just works.

This is kind of documentation...and good enough for people searching for the answer, but I am too busy now to formally add to docs. So, whoever monitors these issues can close this one if no one has time to add to docs. I no longer have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants