https://prefect.io logo
e

Elliott Wilson

07/11/2023, 10:55 AM
Hello I was wondering if anyone have any advice on handling deployments locally vs production. I am currently using a github branch called prefect_test locally but in production I want to use main. Is there way of setting env variables to be use current branch locally and use main in production in the YAML?
Copy code
pull:
    - prefect.deployments.steps.git_clone:
        repository: <https://github.com/gaia-family/monorepo.git>
        branch: prefect_test
        access_token: "{{ prefect.blocks.secret.github-access-token }}"
    - prefect.deployments.steps.set_working_directory:
        id: change_directory
        directory: /monorepo/data/prefect
    - prefect.deployments.steps.pip_install_requirements:
        requirements_file: requirements.txt
n

Nate

07/11/2023, 8:04 PM
hey @Elliott Wilson you could have an env var like
PREFECT_ENV
both on your local dev machine (maybe set to
local
) and in your github repo (
prod
) and then you could
Copy code
pull:
    - prefect.deployments.steps.run_shell_script:
        id: prefect-env
        script: bash -c 'echo $PREFECT_ENV'
        stream_output: true

    - prefect.deployments.steps.git_clone:
        repository: <https://github.com/gaia-family/monorepo.git>
        branch: "{{ prefect-env.stdout }}"
        access_token: "{{ prefect.blocks.secret.github-access-token }}"

    - prefect.deployments.steps.set_working_directory:
        id: change_directory
        directory: /monorepo/data/prefect

    - prefect.deployments.steps.pip_install_requirements:
        requirements_file: requirements.txt