hi prefect community! when working with deployment...
# ask-community
a
hi prefect community! when working with deployments using different infrastructure/storage blocks, is the recommended best practice to just build separate deployment.yamls for each use-case? or is there a way to conditionally apply blocks based on something like environment or workspace?
j
Hi @aaron my favorite way to conditionally apply blocks would be with GitHub actions! You can configure different jobs to use a different
deployment build
command based on which branch you are in. Otherwise there are many other CI/CD options you can use
a
Thanks @James Sopkin! How would one conditionally apply blocks using pure Prefect? Is it possible to define multiple blocks in a single deployment file and use them conditionally? Using Github Actions is fine but what about a local env?
j
Hey Aaron, so here's an example that I used before
Copy code
- if: github.ref == 'refs/heads/main'
        name: Build and apply Prefect deployment
        run: prefect deployment build $FILEPATH -n ${{ matrix.name }} ${{ matrix.schedule }} ${{ matrix.params }} -sb $STORAGE -ib $INFRA -q prod --apply
      - if: github.ref != 'refs/heads/main'
        name: Build and apply Prefect deployment
        run: prefect deployment build $FILEPATH -n ${{ matrix.name }} ${{ matrix.params }} -sb $STORAGE -ib $INFRA -q dev --apply
I would include logic to build out a different deployment for dev and prod and passed in parameters, storage, schedule and infra blocks
a
This is very handy, thank you!
j
You’re welcome!