From 0d3336b8d9eb67387fd705e72c84b2960217af41 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 29 Oct 2023 17:28:45 +0100 Subject: [PATCH] Made check for wether tagged commit is on master more robust --- .github/workflows/publish-to-pypi.yml | 9 +++------ .github/workflows/publish-to-test-pypi.yml | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 7d15b3d..8eebbee 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -19,15 +19,12 @@ jobs: - name: Verify tag is on master branch run: | - TAG_SHA=$(git rev-parse ${{ github.ref }}) - MASTER_SHA=$(git rev-parse refs/heads/master) - - if [ "$TAG_SHA" == "$MASTER_SHA" ]; then - echo "Tag is on the master branch. Proceeding with the workflow." - else + TAG_IS_ON_MASTER=$(git branch -r --contains ${{ github.ref }} | grep 'origin/master') + if [ -z "$TAG_IS_ON_MASTER" ]; then echo "Tag is not on the master branch. Cancelling the workflow." exit 1 fi + echo "Tag is on the master branch. Proceeding with the workflow." - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 54d8dfa..64c1888 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -19,15 +19,12 @@ jobs: - name: Verify tag is on master branch run: | - TAG_SHA=$(git rev-parse ${{ github.ref }}) - MASTER_SHA=$(git rev-parse refs/heads/master) - - if [ "$TAG_SHA" == "$MASTER_SHA" ]; then - echo "Tag is on the master branch. Proceeding with the workflow." - else + TAG_IS_ON_MASTER=$(git branch -r --contains ${{ github.ref }} | grep 'origin/master') + if [ -z "$TAG_IS_ON_MASTER" ]; then echo "Tag is not on the master branch. Cancelling the workflow." exit 1 fi + echo "Tag is on the master branch. Proceeding with the workflow." - name: Set up Python uses: actions/setup-python@v4