Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 3, 2021 04:41 pm GMT

Running GitHub Actions CI/CD triggers on specific branches

GitHub Actions allows you to automate, customize, and execute your software development workflows inside your repository.

You can configure your workflows to run when specific activity on GitHub happens, at a scheduled time, or when an event outside of GitHub occurs.

Screen Shot 2021-02-03 at 11.40.26 AM

The most common events are push and pull_request events. By default, the below workflow will run on any push to any branch and for every pull request opened.

on: [push, pull_request]
Enter fullscreen mode Exit fullscreen mode

If you would like certain events to run on specific branches. You can adjust the YAML to include branch names to only run CI checks on branches you needed them. Below I have changed my events to run on the main branch, even though it is named the push. It will run when you run git push or merge a pull request into the main branch.

on:  push:    branches:    - main  pull_request:    branches:    - main
Enter fullscreen mode Exit fullscreen mode

Finally, you can leverage YAML syntax to run an array of branches. You can also set up wildcards to run on similarly named branches as well.

So now you can set up a workflow to run in multiple branches and maintain separate release tracks. For example:

on:  push:    branches:    - main    - 'releases/**'  pull_request:    branches:    - main    - 'releases/**'
Enter fullscreen mode Exit fullscreen mode

Learn more GitHub Actions tips in our Community Support Forums.

This is part of my 28 days of Actions series. To get notified of more GitHub Action tips, follow the GitHub organization right here on Dev.


Original Link: https://dev.to/github/running-github-actions-ci-cd-triggers-on-specific-branches-5e6m

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To