When using GitHub Actions, is it possible to use a variable for the branch name?
I want to specify the branch name in on > push > branches, but I also want to use it later on in my job, so I am just trying to avoid duplication.
I am using this setup:
name: 'Build and deploy'
on:
push:
branches:
- my-branch
pull_request:
branches:
- my-branch
workflow_dispatch:
env:
GITHUB_BRANCH: 'my-branch'
Doing the following gets marked as an error:
on:
push:
branches:
- ${{ env.GITHUB_BRANCH }} # Unrecognized named-value: env
pull_request:
branches:
- ${{ env.GITHUB_BRANCH }} # Unrecognized named-value: env
workflow_dispatch:
Is there a way to achieve this?