Github Actions - Same workflow name, different branches. Which takes priority?
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?
Assume I have this workflow below on the main branch, but I have a slightly different version on a "dev" branch with the same file name and trigger (both on push branches dev). Would both execute on a push to "dev"?
name: .NET Core CI
on:
push:
branches:
- dev
env:
AZURE_WEBAPP_NAME: ghactiontest # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: '6.0' # set this to the dot net version to use
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@main
# Setup .NET Core SDK
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
# Run dotnet build and publish
- name: dotnet build and publish
run: |
dotnet restore
dotnet build --configuration Release
dotnet publish -c Release -o '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp'
# Deploy to Azure Web apps
- name: 'Run Azure webapp deploy action using publish profile credentials'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation
package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp'
I tested this with a simple hello world workflow on the "main" and "dev" branches. If there is an "on push" trigger for a given branch, the workflow must exist on that branch. A workflow on "main" with a trigger for both "main" and "dev" will only execute on a push to "main" if there's no corresponding workflow on "dev".
name: .NET Core CI Cert
on:
push:
branches:
- cert
- main
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: my-step
run: echo "Hello World Cert Branch!"