diff --git a/.github/workflows/create-publish-docker-image.yml b/.github/workflows/create-publish-docker-image.yml index c2d03d4..a08777a 100644 --- a/.github/workflows/create-publish-docker-image.yml +++ b/.github/workflows/create-publish-docker-image.yml @@ -19,9 +19,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Exit if not on main branch - if: endsWith(github.event.base_ref, 'main') == false - run: exit -1 + - name: Get current branch and exit if not main + run: | + raw=$(git branch -r --contains ${{ github.ref }}) + branch=${raw##*/} + echo "{name}=branch" >> $GITHUB_OUTPUT + echo "Branch is $branch." + if [ "$branch" != "main" ]; then + echo "Not on main branch, exiting." + exit 0 + fi - name: Log in to the Container registry uses: docker/login-action@v2