From the course: Learning GitHub Actions

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Add conditions to a workflow

Add conditions to a workflow - GitHub Tutorial

From the course: Learning GitHub Actions

Add conditions to a workflow

- [Instructor] When we use the push and pull request events to trigger our workflow, we can limit activity to specific branches. To set this up, we need to change our YAML formatting a bit. Instead of using a value for the on key, as we see here, the event needs to be in its own YAML block. Basically, we move the event down to the next line and follow it with a colon to indicate a new block with its own mapping. Now we can add the branches conditional, where we can list the branches we want the workflow to focus on. For example, if we want pushes to our repo to only work on the branches named develop and master, we would add a dash and then list those branch names. If we want pull requests to only work on our master branch, we would add a list entreat with master under the pull request attribute. Now, these examples would be for workflows that only have one trigger, a push or a pull request. What if we have a workflow that's…

Contents