Skip to content

Commit

Permalink
Add prefect token var to CI when needed (#1279)
Browse files Browse the repository at this point in the history
* Add secret config for prefect token into CI

* Simple updates to prefect docs about token env var

* Fix wrong call when missing var from config
  • Loading branch information
viniciusdc authored May 24, 2022
1 parent 43b3274 commit 0b5b098
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/source/admin_guide/prefect.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ prefect:
There are a bunch of components in getting Prefect working for you, here is a brief description of them:

1. Create a free Prefect cloud account here: https://cloud.prefect.io/
2. Create a Service Account and an API key for the same and add this to the CI secrets as `TF_VAR_prefect_token`:
- In GitHub: Set it in Secrets (https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
- In GitLab: Set it as Variables (https://docs.gitlab.com/ee/ci/variables/#gitlab-cicd-variables)
2. Create a Service Account and an API key for the same and add this to the CI secrets as `QHUB_SECRET_PREFECT_TOKEN`:
- In GitHub: Set it in [Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
- In GitLab: Set it as [Variables](https://docs.gitlab.com/ee/ci/variables/#gitlab-cicd-variables)
3. Create a project in the Prefect Cloud Dashboard. Alternatively from CLI:

```
Expand Down
6 changes: 6 additions & 0 deletions qhub/provider/cicd/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def gha_env_vars(config):
if os.environ.get("QHUB_GH_BRANCH"):
env_vars["QHUB_GH_BRANCH"] = "${{ secrets.QHUB_GH_BRANCH }}"

# This assumes that the user is using the omitting sensitive values configuration for the token.
if config.get("prefect", {}).get("enabled", False):
env_vars[
"QHUB_SECRET_prefect_token"
] = "${{ secrets.QHUB_SECRET_PREFECT_TOKEN }}"

if config["provider"] == "aws":
env_vars["AWS_ACCESS_KEY_ID"] = "${{ secrets.AWS_ACCESS_KEY_ID }}"
env_vars["AWS_SECRET_ACCESS_KEY"] = "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
Expand Down

0 comments on commit 0b5b098

Please sign in to comment.