GitHub Actions中的环境与可重用工作流不兼容吗?

huangapple go评论53阅读模式
英文:

Environments in GitHub Actions incompatible with reusable workflows?

问题

我有以下的工作

构建并推送Docker镜像:
名称: 构建并推送Docker镜像
如果: github.repository == 'Org/repo'
使用: Org/repo/.github/workflows/reusable.yaml@main
参数:
dockerfile: My_Dockerfile
环境:
名称: Production
需要:
- job-1
- job-2
密钥:
SECRET_1: ${{ secrets.SECRET_1 }}


这未通过基本的语法检查,报错如下:

> 工作流程无效。.github/workflows/my_workflow.yml (行: 236, 列: 5): 意外的值 'environment'
英文:

I have the following job

  build-and-push-docker-image:
    name: Build and push docker image
    if: github.repository == 'Org/repo'
    uses: Org/repo/.github/workflows/reusable.yaml@main
    with:
      dockerfile: My_Dockerfile
    environment:
      name: Production
    needs:
      - job-1
      - job-2
    secrets:
      SECRET_1: ${{ secrets.SECRET_1 }}

This fails the basic syntax checking as follows:

> The workflow is not valid. .github/workflows/my_workflow.yml (Line: 236, Col: 5): Unexpected value 'environment'

Why is that?

答案1

得分: 2

根据文档,无法在可重复使用的工作流中使用 environment。您需要在可重复使用的工作流内定义它。

查看这里:调用可重复使用工作流的作业支持的关键字

英文:

According to the documentation, it is not possible to use environment with a reusable workflow. You would have to define it within the reusable workflow.

See here: Supported keywords for jobs that call a reusable workflow

huangapple
  • 本文由 发表于 2023年2月8日 22:02:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/75386901.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定