A simple experiment shows that it is not necessary to echo
variable to the $GITHUB_OUTPUT
and it is enough to define it just in the outputs
name: Test outputson: workflow_dispatch:env: BRANCH: mainjobs: variables: name: Compute outputs runs-on: ubuntu-latest outputs: branch: ${{ env.BRANCH }} # branch: ${{ steps.variables.outputs.branch }} steps: - name: Echo if: false run: echo # - name: Set outputs variables # id: variables # run: echo # echo "branch=${{ env.BRANCH }}" >> "$GITHUB_OUTPUT" show: name: Show outputs needs: variables runs-on: ubuntu-latest steps: - name: Echo outputs run: | echo "branch: ${{ needs.variables.outputs.branch }}"
This simplify variables pass, especially when we have a lot of them. It can be used for simple cases when we need just to pass variable value, but not for computations.
A single cons is that we need at least one step in the first job, but we can set a dummy one or disable it.