【发布时间】:2022-01-16 00:13:20
【问题描述】:
如果我在名称和内容相同的两个分支“dev”和“main”中有一个工作流,哪个优先?或者两个工作流程都会运行?如果两个工作流的内容不同,但工作流名称相同会怎样?
假设我在下面的主分支上有这个工作流,但我在具有相同文件名和触发器的“dev”分支上有一个稍微不同的版本(都在 push 分支 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'
【问题讨论】:
-
编辑您的问题并显示工作流程。
-
它可以依赖于工作流触发器。但是,如果它不是(全局)推送触发器,则
default分支工作流将被优先考虑(在您的情况下,主分支)。请注意,如果使用 wokflow_dispatch 触发器,则可以选择执行工作流的分支。
标签: github github-actions