user3222101
user3222101

Reputation: 1330

Github actions: Output from one step is only accessible in the next step and not other steps

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

Upvotes: 1

Views: 513

Answers (1)

rethab
rethab

Reputation: 8413

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

Upvotes: 1

Related Questions