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 prefect token var to CI when needed #1279

Merged
merged 3 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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