Home  >  Article  >  Development Tools  >  do github actions need to be on main branch

do github actions need to be on main branch

Patricia Arquette
Patricia ArquetteOriginal
2024-10-09 15:19:15480browse

Do Github actions need to be on the main branch to run?

No, GitHub actions do not need to be on the main branch to run. GitHub actions can be configured to run on any branch or tag in your repository. To specify which branches or tags an action should run on, use the on keyword in your workflow file. For example:

<code class="yaml">on:
  push:
    branches: [main, develop]</code>

This workflow will run whenever there is a push to either the main or develop branch.

Are Github actions only triggered when they are on the main branch?

No, GitHub actions are not only triggered when they are on the main branch. GitHub actions can be triggered by a variety of events, including:

  • Pushes to branches or tags
  • Pull requests
  • Issues
  • Releases
  • Schedules
  • Webhooks

You can specify which events should trigger an action in your workflow file. For example:

<code class="yaml">on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]</code>

This workflow will run whenever there is a push to the main or develop branches, or when a pull request is opened against the main branch.

Does the location of a Github action affect when it runs?

No, the location of a GitHub action does not affect when it runs. GitHub actions can be run on any of GitHub's hosted runners, or on your own self-hosted runners. The location of the runner will not affect when the action starts running, or how long it takes to complete.

The above is the detailed content of do github actions need to be on main branch. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn