To detect a pull request event that pertains to a particular branch in GitHub actions, you can use the on
keyword in the workflow YAML file to specify the event trigger as follows:
on:
pull_request:
branches:
- branch-name
This will trigger the workflow when a pull request is opened or updated that targets the specified branch (branch-name
).
You can then use the github.event.pull_request.head.ref
context variable in the workflow to get the name of the branch that the pull request is coming from. For example, you can use it in a conditional step like this:
- name: Build and Test
if: github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'branch-name'
run: |
# commands to build and test the code
This will only run the Build and Test
step if the event was a pull request targeting the branch-name
.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-18 13:56:42 +0000
Seen: 12 times
Last updated: May 18 '23
What does the "429 error" in the request response of Instabot mean?
Can migration files be executed in knex upon making an API request?
What is the process of performing a GET request while using OAuth1 authentication?
What does it mean when API Gateway gives a 503 Service Unavailable error?
How can Google OAuth be integrated with FastAPI?
How can Azure DevOps Pull Request and Jenkins be utilized within a corporate network?
How to make an httr SOAP API request using R?
Is it possible for someone to make FieldOutputRequestState functional in Abaqus Scripting?
What is the way to hold off until Flask handles all requests?