GitHub Actions workflow that checks if branch is master
before running job master-check
:
# .github/workflows/check.yml
on: push
jobs:
master-check:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- run: echo "Running on branch $GITHUB_REF"
The if
conditional checks that the branch is master
:
if: github.ref == 'refs/heads/master'
To skip the master
branch, use the !=
operator:
if: github.ref != 'refs/heads/master'
See GitHub Actions documentation example.