Set job environment based on branch name

Hi,

I’m trying to set a job environment based on the branch name, further I’m even combining it with repositry_dispatch:

name: CI

on:
  push:
    branches:
      - main
      - test
      - si
  repository_dispatch:
    types:
      - main
      - test
      - si
      
jobs:
  build:
    environment: ${{ github.event.client_payload.ref == '' && github.ref || github.event.client_payload.ref }} 
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.client_payload.ref }}

      - name: Run a one-line script
        run: |
          echo "${{ github.event }}"
          echo "${{ github.event.client_payload.ref }}"
          echo "${{ github.ref }}"
          echo "stage $ECHO!"  # here should be some other command that actually uses the env 
        env:
          ECHO: ${{secrets.ECHO}}

I would like to get replace the result of github.ref e.g. “refs/heads/si” with the pure branch name.
Is there any way of achieving this?
I mean I can live with the full name but it forces me to name my event_types and environments accordingly.