How to set environment attribute dynamically in a workflow?

Hello, in the settings of my repository I created 2 environments: development and production. I also have 2 branches of the same name. I want my workflow to execute in the corresponding environment (so as to grab the correct git secrets).

This is what I have:

jobs:
  branch-based-execution:
    name: Run external workflow
    environment: ${{ github.ref }}
    runs-on: ubuntu-latest
    steps:
      - name: Echo env var
        env:
          my_var: ${{ secrets.my_var }}
        shell: bash
        run: echo $my_var

However, I get the following error on the environment line:

Unrecognized named-value: ‘github’. Located at position 1 within expression: github.ref

Looks like I can’t use github context to set the environment attribute. Is there a way to set the environment of the workflow dynamically? Thanks!