Home > Mobile >  Github Actions - Same workflow name, different branches. Which takes priority?
Github Actions - Same workflow name, different branches. Which takes priority?

Time:01-14

If I have a workflow in two branches "dev" and "main" with the same name and content, which one takes precedence? Or will both workflows run? What happens if the content of the two workflows is different, but the workflow name is the same?

CodePudding user response:

Normally this workflow will run for both dev and main - can you post your exact workflow?

Two workflows with the same name will also run separately and will be considered two different workflows with two different workflow_ids - but they will appear using the same name.

CodePudding user response:

Since all workflows are suppose to be located in .github/workflows directory and they cannot be inside sub directories theoretically you cannot create more than one workflow with same name in this directory. To answer your other question, if you want to run a workflow for a specific branch you can use the branch syntax as following:

on:
  push:
    branches:
      - main

Just create your workflows with different names and let them get triggered when push or pull request event is triggered for respective branch.

  •  Tags:  
  • Related