Skip to content

Deploy from CI

For GitHub Actions or any place without a browser, use an API token.

  1. In the dashboard open Settings → Developer, find Token for CI and create a token. Copy it right away, it is shown once.
  2. Save it as a repository secret named DJANGOCLOUD_TOKEN.
  3. Deploy with --no-input so the CLI never prompts and never opens a browser.
- run: pip install djangocloud-cli
- run: djangocloud --no-input deploy --project my-shop
env:
DJANGOCLOUD_TOKEN: ${{ secrets.DJANGOCLOUD_TOKEN }}

If the project has run_tests switched on (see Tests before deploys), djangocloud deploy runs the tests first, on the CI machine, and stops if one fails. Install your test dependencies in the job before you deploy. A script or CI job is never asked whether to switch tests on: --no-input leaves the setting exactly as it is in .djangocloud/config.json.

If you already run the tests in an earlier step, pass --skip-tests to the deploy to avoid running them twice. The release is then recorded as “tests skipped”, so a project that requires passing tests would refuse it.

If your secrets live in GitHub, push them to the project before each deploy. Name the variables to send with --from-env, and map each one from a secret. Empty ones are skipped and reported by name, so optional secrets can stay unset:

- run: pip install djangocloud-cli
- run: >
djangocloud --no-input env push --project my-shop
--from-env DJANGO_SECRET_KEY DATABASE_URL STRIPE_SECRET_KEY
env:
DJANGOCLOUD_TOKEN: ${{ secrets.DJANGOCLOUD_TOKEN }}
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
- run: djangocloud --no-input deploy --project my-shop
env:
DJANGOCLOUD_TOKEN: ${{ secrets.DJANGOCLOUD_TOKEN }}

Rotating a secret is then: change it in GitHub and re-run the workflow. env push only adds and overwrites, so it never deletes a variable you set in the dashboard. See Environment variables.

Terminal window
djangocloud --no-input rollback 3 --project my-shop

CI can’t pick from a list, so give the release number. See Releases and rollbacks.

Give it everything up front:

Terminal window
djangocloud --no-input deploy --name "My Shop" --size nano --own-cloud

Pass it explicitly:

Terminal window
djangocloud --no-input deploy --project my-shop --asgi-module config.asgi:application
Variable Purpose
DJANGOCLOUD_TOKEN API token for CI. Takes precedence over a stored login.
DJANGOCLOUD_NO_INPUT Same as --no-input (set it to 1).
DJANGOCLOUD_API API base URL. The default is https://djangocloud.dev/api/v1.

Revoke a token any time under Settings → Developer in the dashboard.