I have a GitHub action running my unit tests for a web app. I run CodeClimate test reporting from this action.
CodeClimate requires two environment variables to be set for the report to be correctly sent. These are;
- GIT_SHA
- GIT_BRANCH
GitHub actions makes the git commit sha avaiable through the github context via github.sha
so I can set an environment variable on the action like this;
env:
GIT_SHA: ${{ github.sha }}
However github actions does not make the branch name available.
It does provide a default environment variable called GITHUB_REF
this is the full ref but I understand that I can grab the short ref i.e. the branch name using this shorthand syntax $GITHUB_REF##*/
The problem I have is that I cannot set an env variable called GITHUB_BRANCH with this value $GITHUB_REF##*/
Does anyone how I might get the branch name and set it to the environment variable GIT_BRANCH
so the CodeClimate test script would be able to use it.
Ultimately I want my env config to look like this:
env:
GIT_SHA: <git commit sha>
GIT_BRANCH: <current git branch>