I'd like a Github action to run on Pull Request to a specific base branch, but from another specific head branch.
name: Run production tests
on:
push:
pull_request:
branches:
- main
jobs: ...
However, I specifically want something like this to run when a branch called develop
is PR'd against main
, not just every time something is PR'd to main
.
Is such a workflow possible? I might be missing it, but I don't see a way to target head branches in the docs.
CodePudding user response:
From the documentation, I could not find any filters for the head branch. But this is doable with if
conditions for jobs.
For example
name: Run production tests
on:
pull_request:
branches:
- main
jobs:
build:
if: ${{ github.head_ref == 'develop'}}
runs-on: ubuntu-latest
steps:
- name: Run a multi-line script
run: |
echo "Do something here"