重复使用github操作工作流程

发布于 2025-01-23 18:18:04 字数 588 浏览 1 评论 0原文

在这里,我想创建分支部署管道。部署将在每个拉的请求下完成,我们需要获取一个分支名称,以便我们调用该分支名称的工作流程。我试图以下面的方式进行操作,但是它给出了错误。

on:
  pull_request:
    types: [opened, synchronize, reopened]
env:
  WORKFLOW: 'bigelio/todo/.github/workflows/branch-deployment-serverless-deploy.yml@${{ github.head_ref }}'

deploy:
    needs: [terraform]

    uses: $WORKFLOW
    secrets:
      TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}

我在github中遇到的错误是

    Invalid workflow file: .github/workflows/branch-deployment-workflow.yml#L198
invalid value workflow reference: no version specified

Here I want to create branch deployment pipeline. Deployment will be done on every pull request and we need to get a branch name, so that we call a workflow with that branch name. I have tried to do it in the following way, But it is giving an error.

on:
  pull_request:
    types: [opened, synchronize, reopened]
env:
  WORKFLOW: 'bigelio/todo/.github/workflows/branch-deployment-serverless-deploy.yml@${{ github.head_ref }}'

deploy:
    needs: [terraform]

    uses: $WORKFLOW
    secrets:
      TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}

The error I am getting in github is this

    Invalid workflow file: .github/workflows/branch-deployment-workflow.yml#L198
invalid value workflow reference: no version specified

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏日浅笑〃 2025-01-30 18:18:04

它不起作用,因为env上下文在跑步者上可用,而use在安排/创建跑步者之前对进行评估。

您可以尝试使用gh CLI与以下内容:GH Workflow Run Triage.yml -Ref my-Branch

另外,您可以查看会适合您的需求。

It doesn't work because env context is available on a runner, while uses is evaluated outside that context, before runner is scheduled/created.

You can try using gh cli with something like: gh workflow run triage.yml --ref my-branch.

Alternatively, you could see if Environments would suite your needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文