简体   繁体   中英

deploy Django application to heroku by GitLab

I have a Django repository on Django and want to deploy the application on Heroku.

I was going through the documentation of GitLab https://docs.gitlab.com/ce/ci/examples/test-and-deploy-python-application-to-heroku.html#configure-project

Which is asking to create two variables

   HEROKU_STAGING_API_KEY
   HEROKU_PRODUCTION_API_KEY

It also states

You'll need to create two variables in Project > Variables:

and

Find your Heroku API key in Manage Account (https://dashboard.heroku.com/account)

The link to heroku dashboard revels only API key which might be used but for which variable, I'm not getting it.

Also from where to get another variable value?

Also there is no option like Project > Variables in GitLab project, so where should I create the specified variables?

The two variables HEROKU_STAGING_API_KEY and HEROKU_PRODUCTION_API_KEY are arbitrary names for a Heroku API key. They are intended to be used by your GitLab CI Pipeline, so they should be stored in GitLab. See GitLab Secret Variables for info on where to place them.

The Heroku API key, like you said, is found in the Heroku Account page. If you plan on using the same Heroku account for staging and production, then you can use the same API key for both HEROKU_STAGING_API_KEY and HEROKU_PRODUCTION_API_KEY . However, in that case it would make more sense to create just one variable in GitLab, say HEROKU_API_KEY , and use it in your gitlab-ci.yml like: --api-key=$HEROKU_API_KEY .

The example in the GitLab documentation just shows you that they are using two different keys, one for staging and one for production. In other words, instead of..

dpl --provider=heroku --app=gitlab-ci-python-test-staging --api-key=$HEROKU_STAGING_API_KEY

and

dpl --provider=heroku --app=gitlab-ci-python-test-prod --api-key=$HEROKU_PRODUCTION_API_KEY

you can just use dpl ... --api-key=$MY_HEROKU_API_KEY_NAME_HERE for both staging and production jobs. Remember to change the --app= to the correct Heroku app name for each job if you choose to go this route.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM