I need to release package only if pushed tag is on master branch.
For now I tried something like that:
verification:
runs-on: self-hosted
container:
image: docker_server.com/python:3.10 # fake path to docker image
credentials:
username: user_name
password: user_pass
steps:
- name: clone repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch all tags and branches
run: |
git tag -l | xargs git tag -d
git fetch --all
git fetch --tags
- name: Check if tag is on master
run: |
git_tag_name="$(echo ${{ github.ref }} | cut -d'/' -f3)"
hash_tag=$(git rev-list -n 1 $git_tag_name)
if git branch --contains $hash_tag | sed -e 's/* //g' -e 's/ //g' | grep -w 'master'; then
echo "Commit on master"
else
echo "Commit not on branch"
exit 1
fi
Those commands work on my local repository but in GitHub this job is failing with message that my tag commit is not on master.
I set fetching level to 0 but it still the same.