Jobs outputs is not working

I have this job, and it builds the docker container and pushes correctly

jobs:
  build-postgres:
    runs-on: ubuntu-latest
    timeout-minutes: 2
    outputs:
      tag: ${{ steps.tag.outputs.tag }}
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: docker/setup-buildx-action@v1
      - uses: actions/cache@v2
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-
      - uses: ./.github/actions/git-short-ref
        id: ref
      - uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - uses: aws-actions/amazon-ecr-login@v1
        id: login-ecr
      - run: echo -n ::set-output name=tag::"${{ steps.login-ecr.outputs.registry }}/cloud-stack/postgres:${{ steps.ref.outputs.ref }}"
        id: tag
      - uses: docker/build-push-action@v2
        id: build
        with:
          context: postgres
          file: postgres/Dockerfile
          load: true
          tags: ${{ steps.tag.outputs.tag }}
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache
      - run: docker push ${{ steps.tag.outputs.tag }}

but in this job where I go to rely on the needs output of the previous job it doesn’t work, it’s just empty.

  test-migrations:
    needs: [build-postgres, build-migrations]
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v2
      - uses: docker/setup-buildx-action@v1
      - uses: actions/cache@v2
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-
      - uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - uses: aws-actions/amazon-ecr-login@v1
        id: login-ecr
      - run: docker network create skynet
      - run: |
          set -e
          export ID=$(docker run \
            --publish 5432:5432 \
            --network skynet \
            --network-alias db.host \
            --env-file .github/env/postgres \
            --detach ${{ needs.build-postgres.outputs.tag }} )
          echo -n "::set-output name=container-id::$ID"
        shell: bash
        id: pg-run

I don’t see a problem with my code, but there must be, what am I don’t wrong?

@xenoterracide,

Try this to see if it can work:

echo "::set-output name=tag::${{ steps.login-ecr.outputs.registry }}/cloud-stack/postgres:${{ steps.ref.outputs.ref }}"

In addition, make sure the jobs “build-postgres”, “build-migrations” and “test-migrations” are in the same workflow run.

jobs:
  experiement:
    runs-on: ubuntu-latest
    outputs:
      registry: ${{ steps.registry.outputs.registry }}
    steps:
      - run: echo "::set-output name=registry::myregistry"
        id: registry
  peer:
    needs: [experiement]
    timeout-minutes: 5
    runs-on: ubuntu-latest
    steps:
      - run: echo ${{ needs.experiement.outputs.registry }}

yes I know about the spelling error

seems like this is working but if I do exactly the same thing with actual registry output, I don’t get any output.

  experiement:
    runs-on: ubuntu-latest
    outputs:
      registry: ${{ steps.login-ecr.outputs.registry }}
    steps:
      - uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - uses: aws-actions/amazon-ecr-login@v1
        id: login-ecr

@xenoterracide,

Can the value of the output be get normally at the subsequent steps in the same job where the output is set?
In your case, if you set a step in “experiement” job to read the value of the output, does it can work normally?

jobs:
  experiement:
    runs-on: ubuntu-latest
    outputs:
      registry: ${{ steps.registry.outputs.registry }}
    steps:
      - run: echo "::set-output name=registry::myregistry"
        id: registry

      - name: view output
        run: echo "steps.registry.outputs.registry = ${{ steps.registry.outputs.registry }}"