github动作:从一个步骤输出仅在下一步而不是其他步骤中访问

发布于 2025-02-08 16:11:59 字数 1353 浏览 1 评论 0原文

我有以下gitHub操作,其中我将发布版本存储在管理器作业中,并将其用于与Manager-uat和Manager-Production的部署中,并且正在发生奇怪的事情,我在Manager-uat中获得了输出current_version,但不在经理生产,而我指的是同一变量。请有人建议。

  manager:
    runs-on: ubuntu-latest
    outputs:
          CURRENT_VERSION: ${{ steps.status.outputs.CURRENT_VERSION }}
          NEED_RELEASE: ${{ steps.status.outputs.NEED_RELEASE }}
    steps:
      - uses: actions/checkout@v2
      - <more steps>

      - name: manager - Check the current version
        working-directory: .
        run: |
          echo "CURRENT_VERSION=$(python tools/check_version.py manager)" >> $GITHUB_ENV

      - id: status
        run: |
          echo "::set-output name=CURRENT_VERSION::${{ env.CURRENT_VERSION }}"
          echo "::set-output name=NEED_RELEASE::${{ env.NEED_RELEASE }}"
  manager_uat:
    needs: [manager]
    if: needs.manager.outputs.NEED_RELEASE == 'true'
    uses: ./.github/workflows/cd_mlops.yml
    secrets: inherit
    with:
      version: ${{needs.manager.outputs.CURRENT_VERSION}}
      service: manager
      envir: uat
  manager_production:
    needs: [ manager_uat ]
    if: needs.manager.outputs.NEED_RELEASE == 'true'
    uses: ./.github/workflows/cd_mlops.yml
    secrets: inherit
    with:
      version: ${{needs.manager.outputs.CURRENT_VERSION}}
      service: manager
      envir: production

I have the below github actions where i am storing the release version in manager job and using it in the deployment with manager-uat and manager-production and a weird thing is happening that i get the output current_version available in manager-uat but not in manager-production whereas i am referring to the same variable. Please can somebody suggest.

  manager:
    runs-on: ubuntu-latest
    outputs:
          CURRENT_VERSION: ${{ steps.status.outputs.CURRENT_VERSION }}
          NEED_RELEASE: ${{ steps.status.outputs.NEED_RELEASE }}
    steps:
      - uses: actions/checkout@v2
      - <more steps>

      - name: manager - Check the current version
        working-directory: .
        run: |
          echo "CURRENT_VERSION=$(python tools/check_version.py manager)" >> $GITHUB_ENV

      - id: status
        run: |
          echo "::set-output name=CURRENT_VERSION::${{ env.CURRENT_VERSION }}"
          echo "::set-output name=NEED_RELEASE::${{ env.NEED_RELEASE }}"
  manager_uat:
    needs: [manager]
    if: needs.manager.outputs.NEED_RELEASE == 'true'
    uses: ./.github/workflows/cd_mlops.yml
    secrets: inherit
    with:
      version: ${{needs.manager.outputs.CURRENT_VERSION}}
      service: manager
      envir: uat
  manager_production:
    needs: [ manager_uat ]
    if: needs.manager.outputs.NEED_RELEASE == 'true'
    uses: ./.github/workflows/cd_mlops.yml
    secrets: inherit
    with:
      version: ${{needs.manager.outputs.CURRENT_VERSION}}
      service: manager
      envir: production

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

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

发布评论

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

评论(1

神也荒唐 2025-02-15 16:11:59

如果x不是直接 direct 作业的依赖性,则不能使用需求。

因此,在您的情况下,您需要添加Manager作为Manager_production之类的依赖性:

  manager_production:
    needs: [ manager, manager_uat ]
    if: needs.manager.outputs.NEED_RELEASE == 'true'
    uses: ./.github/workflows/cd_mlops.yml
    # ..etc

You cannot use needs.X if X is not a direct dependency of the job.

So in your case, you need to add manager as a dependency of manager_production like so:

  manager_production:
    needs: [ manager, manager_uat ]
    if: needs.manager.outputs.NEED_RELEASE == 'true'
    uses: ./.github/workflows/cd_mlops.yml
    # ..etc
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文