我正在尝试创建一个 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 …Run Code Online (Sandbox Code Playgroud)