英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论