How to get the Current Job Environment Name?

In the example below, how would I get the name of the current environment. My only reason for doing this is to keep the code DRY.

    name: "Terraform deploy to test"
    runs-on: ubuntu-latest
    environment: test
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v1
          cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
      - name: Terraform Workspace
        id: workspace
        run: echo "TF_WORKSPACE=${{ }}" >> $GITHUB_ENV

${{ }} doesn’t seem to contain anything and I can’t see it in the list of env variables either?

1 Like

jobs.<job_id>.name is mentioned in:

you could also set a custom variable to keep it DRY:

To set custom environment variables, you need to specify the variables in the workflow file. You can define environment variables for a step, job, or entire workflow using the jobs.<job_id>.steps[*].env , jobs.<job_id>.env , and env keywords. For more information, see “Workflow syntax for GitHub.”