Skip to content

Release: Bump version to v0.2.0 stable #23

Release: Bump version to v0.2.0 stable

Release: Bump version to v0.2.0 stable #23

name: 'Branch Protection'
on:
workflow_dispatch:
pull_request:
branches:
- '**'
jobs:
protect-main-branch:
runs-on: ubuntu-latest
steps:
- name: Ensure PRs are only from allowed branches
run: |
# Check if the target branch is 'main'
if [[ "${GITHUB_BASE_REF}" == "main" ]]; then
# If targeting 'main', ensure source branch is either 'release/*' or 'hotfix/*'
if ! [[ ${GITHUB_HEAD_REF} =~ ^(release/|hotfix/).+ ]]; then
echo "Error: Pull requests to main can only be from 'release/*' or 'hotfix/*' branches."
exit 1
else
echo "Pull request to main from allowed branch '${GITHUB_HEAD_REF}'."
fi
else
# If not targeting 'main', skip the check and pass
echo "Pull request is not targeting 'main'; no protection checks required."
fi