I have a GitHub action workflow for a swift package that runs whenever something is merged to the main branch. My goal is to check the for a source branch and depending on its prefix (i.e. patch/something) determine wow to tag and release it.
This is how I have it configured so far:
name: Release
on:
push:
branches:
- main
jobs:
build:
runs-on: macos-latest
patch-release-on-push:
needs: build
if: contains(github.head_ref, 'patch')
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- id: release
uses: rymndhng/release-on-push-action@master
with:
bump_version_scheme: patch
The problem with this is that github.head_ref is null. I only get a value on it if I switch the workflow to be triggered on a pull_request instead of push which wouldn’t really work given that the release would be out before the PR was merged.
What’s the right approach for achieving this?