Home > Development Tools > git > body text

do github actions need to be on main branch

Patricia Arquette
Release: 2024-10-09 15:19:15
Original
463 people have browsed it

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>
Copy after login

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!