gpt4 book ai didi

github - 如何从 master 以外的分支运行 GitHub Action?

转载 作者:行者123 更新时间:2023-12-03 15:47:01 27 4
gpt4 key购买 nike

我在 GitHub 中有一个 repo,我想创建一个 Action 来构建 Docker 镜像并将其推送到 DockerHub。我知道该怎么做,但是:如果我在 master GitHub 以外的分支中创建操作,则不会运行它。
这是一个已知问题( Workflow files only picked up from master? )。
任何想法来解决它?

最佳答案

根据官方 GitHub Actions 文档(About workflow events):

The following steps occur to trigger a workflow run:

  1. An event occurs on your repository, and the resulting event webhook has an associated commit SHA and Git ref.

  2. The .github/workflows directory in your repository is searched for workflow files at the associated commit SHA or Git ref. The workflow files must be present in that commit SHA or Git ref to be considered.

    For example, if the event occurred on a particular repository branch, then the workflow files must be present in the repository on that branch.

  3. The workflow files for that commit SHA and Git ref are inspected, and a new workflow run is triggered for any workflows that have on: values that match the triggering event.

    The workflow runs on your repository's code at the same commit SHA and Git ref that triggered the event. When a workflow runs, GitHub sets the GITHUB_SHA (commit SHA) and GITHUB_REF (Git ref) environment variables in the runner environment. For more information, see "Using environment variables."


因此,为了测试工作流,我们需要在创建的分支中执行 git 操作(即 do push )。

关于github - 如何从 master 以外的分支运行 GitHub Action?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63480433/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com