I\'m building docker images with Github Actions and want to tags images with branch name,
I found only GITHUB_REF variable, but it results in refs/heads/f
I just made a simple test within GitHub Actions using a bash script:
#!/bin/bash
echo Reserved for REPO_NAME=${GITHUB_REPOSITORY##*/}
echo GITHUB_REF=${GITHUB_REF}
echo EXTRACT_GITHUB_REF=${GITHUB_REF##*/}
echo EXTRACT_GITHUB_REF_HEADS=$(echo ${GITHUB_REF#refs/heads/})
cd $REPO_NAME
git checkout ${GITHUB_REF##*/}
git checkout $(echo ${GITHUB_REF#refs/heads/})
Here is screenshot of the output:
So both ${GITHUB_REF##*/} and $(echo ${GITHUB_REF#refs/heads/}) are correct