Martijn van Elferen
10/30/2023, 2:09 PMMarvin
10/30/2023, 2:10 PMbash
#!/bin/bash
# Set the branch based on the environment
if [ "$ENV" == "preproduction" ]
then
BRANCH="develop"
elif [ "$ENV" == "production" ]
then
BRANCH="master"
else
echo "Invalid environment '$ENV'. Please set ENV to either 'preproduction' or 'production'."
exit 1
fi
# Clone the repo
git clone -b $BRANCH <https://github.com/your-repo.git>
In this script, ENV
is an environment variable that you would set to either "preproduction" or "production" before running the script. The script then sets the BRANCH
variable to either "develop" or "master" based on the value of ENV
, and clones the appropriate branch of your repository.
Remember to replace <https://github.com/your-repo.git>
with the URL of your own repository.
Now, if you'll excuse me, I have to go back to contemplating the vast emptiness of the universe. It's a tough job, but someone's got to do it.Martijn van Elferen
10/30/2023, 2:13 PMNate
10/30/2023, 2:23 PMMartijn van Elferen
10/30/2023, 2:26 PMNate
10/30/2023, 2:32 PMdeployment_env
env var on your work pool set to something like "preProd" and you want your pull step to clone that branch of the repo and run it?Martijn van Elferen
10/30/2023, 2:33 PMNate
10/30/2023, 2:50 PM- name: env-check
entrypoint: src/demo_project/healthcheck.py:healthcheck
work_pool:
name: local
job_variables:
env:
FOO: bar # this could be stored as a variable or secret if desired
pull:
- prefect.deployments.steps.run_shell_script:
id: env-check
script: echo $FOO
stream_output: true
expand_env_vars: true
- prefect.deployments.steps.git_clone:
repository: <https://github.com/zzstoatzz/prefect-monorepo>
branch: "{{ env-check.stdout }}"
Martijn van Elferen
10/30/2023, 3:03 PMMartijn van Elferen
10/30/2023, 3:29 PMNate
10/30/2023, 3:31 PMenv
that you set. so it should be accessible like any other env varMartijn van Elferen
10/30/2023, 3:33 PM