3

I am just experimenting with GitHub action and I have the following workflow.

  1. when a developer finishes a feature and creates a PR on (branch name can be in the format of feature/ticketno ), I would like to run some tests against the newly created PR branch.

one solution I found is to add an if condition in the action steps to avoid running tests against the desired branches on the PR up(ie master, staging).

But not sure this is the right approach I looking for a proper solution

asked Mar 19, 2021 at 18:47

1 Answer 1

6

Github actions supports triggering a build when a pull request is created pointing to a specified branch or on a push to a wildcard branch. Your scenario would require custom conditions. You might find a good compromise by using branches-ignore and types

here's an example of a wildcard feature branches, push vs pull_request trigger

on:
 push:
 branches:
 - main
 - dev
 - feature/*
 pull_request:
 branches: 
 - main
 - dev

Also check this Q&A GitHub actions to trigger build on new Pull Requests

For reference and all available options https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions

answered Mar 19, 2021 at 23:36
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.