我正在尝试创建一个 GitHub Actions 工作流程,其中一项作业对其environment设置具有动态值。https://docs.github.com/en/actions/reference/environments我在此工作流程中有两项工作。第一个作业决定第二environment个作业将在哪个作业中运行,而这又取决于操作作业从哪个 git 分支运行。
这是我天真的尝试让它工作,但我收到一个错误,上面写着
\n\n\n(行:29,列:18):无法识别的命名值:\'需要\'。位于表达式中的位置 1:needs.get-environment.outputs.environment_name
\n
name: Environments\n\non:\n push:\n workflow_dispatch:\n\njobs:\n get-environment:\n runs-on: ubuntu-latest\n outputs:\n environment_name: ${{ steps.get_environment.outputs.environment_name }}\n steps:\n - id: get_environment\n run: |\n if [ "$GITHUB_REF" = "refs/heads/test" ]\n then\n echo "::set-output name=environment_name::test"\n elif [ "$GITHUB_REF" = "refs/heads/qa" ]\n then\n echo "::set-output name=environment_name::qa"\n elif [ "$GITHUB_REF" = "refs/heads/master" ]\n then\n echo "::set-output name=environment_name::production"\n fi\n \n use-environment:\n runs-on: ubuntu-latest\n needs: [get-environment]\n environment: ${{ needs.get-environment.outputs.environment_name }}\n steps:\n - uses: actions/checkout@v2\n\n - name: Run a one-line script\n run: echo ${{ secrets.ENV_DEPENDENT_SECRET\xc2\xa0}}\nRun Code Online (Sandbox Code Playgroud)\n有可能实现我想要做的事情吗?我的最终目标是为三个不同的应用程序环境(测试、QA 和产品)提供一个工作流程文件,其中每个应用程序环境使用单独的 Actions environment。(我知道术语会让人困惑)
小智 0
你有没有尝试过
> use-environment:
> runs-on: ubuntu-latest
> needs: [get-environment]
> environment:
> name: ${{ needs.get-environment.outputs.environment_name }}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6888 次 |
| 最近记录: |