[GH-ISSUE #758] Issue: Only first step is able to set output variables #478

Closed
opened 2026-03-01 21:43:46 +03:00 by kerem · 8 comments
Owner

Originally created by @domenix on GitHub (Jul 20, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/758

System information

  • Operating System: Windows 10
  • Architecture: x64 (64-bit)
  • Apple M1: no
  • Docker version: 20.10.7
  • act version: c865a56 (current commit on master at the time of submission)

Expected behaviour

Output variables should be able to be defined in multiple steps under the same job

Actual behaviour

Currently, output variables can only be successfully defined in the first step inside a job (see official documentation for reference).

Workflow and/or repository

workflow
name: Test
on:
  workflow_dispatch:

jobs:
  set_vars:
    name: Set variables
    runs-on: ubuntu-latest
    steps:
    - id: set_1
      run: |
        echo "::set-output name=var_1::$(echo hello)"
        echo "::set-output name=var_2::$(echo world)"
    - id: set_2
      run: echo "::set-output name=var_3::$(echo 1234)"
    outputs:
      variable_1: ${{ steps.set_1.outputs.var_1 }}
      variable_2: ${{ steps.set_1.outputs.var_2 }}
      variable_3: ${{ steps.set_2.outputs.var_3 }}
  printing:
    name: Printing
    needs: set_vars
    runs-on: ubuntu-latest
    steps:
      - name: Print variables from another job
        run: |
          echo "${{ needs.set_vars.outputs.variable_1 }}" # Gets printed
          echo "${{ needs.set_vars.outputs.variable_2 }}" # As well
          echo "${{ needs.set_vars.outputs.variable_3 }}" # Empty space in logs, variable not resolved

Steps to reproduce

Run: act workflow_dispatch -W <path to the workflow file with content above>

act output

Log
[Test/Set variables] 🚀  Start image=catthehacker/ubuntu:act-latest
[Test/Set variables]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Test/Set variables]   🐳  docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root
[Test/Set variables] ⭐  Run echo "::set-output name=var_1::$(echo hello)"
echo "::set-output name=var_2::$(echo world)"
[Test/Set variables]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /mnt/c/testrepo/workflow/set_1] user=
[Test/Set variables]   ⚙  ::set-output:: var_1=hello
[Test/Set variables]   ⚙  ::set-output:: var_2=world
time="2021-07-20T21:21:08+02:00" level=error msg="Unable to interpolate string '${{ steps.set_2.outputs.var_3 }}' - [TypeError: Cannot access member 'outputs' of undefined]"
[Test/Set variables]   ✅  Success - echo "::set-output name=var_1::$(echo hello)"
echo "::set-output name=var_2::$(echo world)"
[Test/Set variables] ⭐  Run echo "::set-output name=var_3::$(echo 1234)"
[Test/Set variables]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /mnt/c/testrepo/workflow/set_2] user=
[Test/Set variables]   ⚙  ::set-output:: var_3=1234
[Test/Set variables]   ✅  Success - echo "::set-output name=var_3::$(echo 1234)"
[Test/Printing     ] 🚀  Start image=catthehacker/ubuntu:act-latest
[Test/Printing     ]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Test/Printing     ]   🐳  docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root
[Test/Printing     ] ⭐  Run Print variables from another job
[Test/Printing     ]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /mnt/c/testrepo/workflow/0] user=
| hello
| world
| 
[Test/Printing     ]   ✅  Success - Print variables from another job

Comments

May relate to issue 295 based on the comments at the end, but this one is a different issue as needs now work on the master branch, although not released yet.

This can affect workflows where the first step pulls in an action, e.g. using the digitalocean/action-doctl@v2 as the first step in order to execute doctl commands that gets the IP address of a Droplet and sets it as the output in the second step will not be possible due to this issue.

Originally created by @domenix on GitHub (Jul 20, 2021). Original GitHub issue: https://github.com/nektos/act/issues/758 ## System information - Operating System: Windows 10 - Architecture: x64 (64-bit) - Apple M1: no - Docker version: 20.10.7 - `act` version: c865a56 (current commit on `master` at the time of submission) ## Expected behaviour Output variables should be able to be defined in multiple steps under the same job ## Actual behaviour Currently, output variables can only be successfully defined in the first step inside a job (see official [documentation](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs) for reference). ## Workflow and/or repository <details> <summary>workflow</summary> ```yml name: Test on: workflow_dispatch: jobs: set_vars: name: Set variables runs-on: ubuntu-latest steps: - id: set_1 run: | echo "::set-output name=var_1::$(echo hello)" echo "::set-output name=var_2::$(echo world)" - id: set_2 run: echo "::set-output name=var_3::$(echo 1234)" outputs: variable_1: ${{ steps.set_1.outputs.var_1 }} variable_2: ${{ steps.set_1.outputs.var_2 }} variable_3: ${{ steps.set_2.outputs.var_3 }} printing: name: Printing needs: set_vars runs-on: ubuntu-latest steps: - name: Print variables from another job run: | echo "${{ needs.set_vars.outputs.variable_1 }}" # Gets printed echo "${{ needs.set_vars.outputs.variable_2 }}" # As well echo "${{ needs.set_vars.outputs.variable_3 }}" # Empty space in logs, variable not resolved ``` </details> ## Steps to reproduce Run: `act workflow_dispatch -W <path to the workflow file with content above>` <!-- - Make sure to include full command with parameters you used to run `act`, example: 1. Clone example repo (https://github.com/cplee/github-actions-demo) 2. Enter cloned repo directory 3. Run `act -s SUPER_SECRET=im-a-value` --> ## `act` output <!-- - Use `act` with `-v`/`--verbose` and paste output from your terminal in code block below --> <details> <summary>Log</summary> ```none [Test/Set variables] 🚀 Start image=catthehacker/ubuntu:act-latest [Test/Set variables] 🐳 docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [Test/Set variables] 🐳 docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root [Test/Set variables] ⭐ Run echo "::set-output name=var_1::$(echo hello)" echo "::set-output name=var_2::$(echo world)" [Test/Set variables] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /mnt/c/testrepo/workflow/set_1] user= [Test/Set variables] ⚙ ::set-output:: var_1=hello [Test/Set variables] ⚙ ::set-output:: var_2=world time="2021-07-20T21:21:08+02:00" level=error msg="Unable to interpolate string '${{ steps.set_2.outputs.var_3 }}' - [TypeError: Cannot access member 'outputs' of undefined]" [Test/Set variables] ✅ Success - echo "::set-output name=var_1::$(echo hello)" echo "::set-output name=var_2::$(echo world)" [Test/Set variables] ⭐ Run echo "::set-output name=var_3::$(echo 1234)" [Test/Set variables] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /mnt/c/testrepo/workflow/set_2] user= [Test/Set variables] ⚙ ::set-output:: var_3=1234 [Test/Set variables] ✅ Success - echo "::set-output name=var_3::$(echo 1234)" [Test/Printing ] 🚀 Start image=catthehacker/ubuntu:act-latest [Test/Printing ] 🐳 docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [Test/Printing ] 🐳 docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root [Test/Printing ] ⭐ Run Print variables from another job [Test/Printing ] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /mnt/c/testrepo/workflow/0] user= | hello | world | [Test/Printing ] ✅ Success - Print variables from another job ``` </details> ## Comments May relate to [issue 295](https://github.com/nektos/act/issues/295) based on the comments at the end, but this one is a different issue as `needs` now work on the master branch, although not released yet. This can affect workflows where the first step pulls in an action, e.g. using the digitalocean/action-doctl@v2 as the first step in order to execute `doctl` commands that gets the IP address of a Droplet and sets it as the output in the second step will not be possible due to this issue.
kerem 2026-03-01 21:43:46 +03:00
Author
Owner

@thejpanganiban commented on GitHub (Aug 13, 2021):

Same experience on my end!

<!-- gh-comment-id:898643151 --> @thejpanganiban commented on GitHub (Aug 13, 2021): Same experience on my end!
Author
Owner

@BlackDex commented on GitHub (Aug 26, 2021):

Same here using Linux and de44a50.

<!-- gh-comment-id:906473968 --> @BlackDex commented on GitHub (Aug 26, 2021): Same here using Linux and `de44a50`.
Author
Owner

@pcfighter commented on GitHub (Oct 14, 2021):

I've debugged it a bit, used workflow from issue content. When you check step value here:
https://github.com/nektos/act/blob/master/pkg/runner/step_context.go#L64

you will see that while still being on step set_1 runner is trying to interpolate values from other step set_2, which sounds wrong.

<!-- gh-comment-id:943787298 --> @pcfighter commented on GitHub (Oct 14, 2021): I've debugged it a bit, used workflow from issue content. When you check step value here: https://github.com/nektos/act/blob/master/pkg/runner/step_context.go#L64 you will see that while still being on step `set_1` runner is trying to interpolate values from other step `set_2`, which sounds wrong.
Author
Owner

@BlackDex commented on GitHub (Oct 14, 2021):

I tested the fix from @ChristopherHX github.com/ChristopherHX/act@fd9f40cdc0 that seems to work perfectly.

<!-- gh-comment-id:943829540 --> @BlackDex commented on GitHub (Oct 14, 2021): I tested the fix from @ChristopherHX https://github.com/ChristopherHX/act/commit/fd9f40cdc02dc72c40a9c33450d638d6e8e8ee57 that seems to work perfectly.
Author
Owner

@chaoedu commented on GitHub (Oct 15, 2021):

I tested the fix from @ChristopherHX ChristopherHX@fd9f40c that seems to work perfectly.

So did I.

<!-- gh-comment-id:943921804 --> @chaoedu commented on GitHub (Oct 15, 2021): > I tested the fix from @ChristopherHX [ChristopherHX@fd9f40c](https://github.com/ChristopherHX/act/commit/fd9f40cdc02dc72c40a9c33450d638d6e8e8ee57) that seems to work perfectly. So did I.
Author
Owner

@BlackDex commented on GitHub (Nov 20, 2021):

@catthehacker any chance of this being fixed via the changes @ChristopherHX made being implemented into the this branch?
What is needed for this to be fixed/tested further?

<!-- gh-comment-id:974633710 --> @BlackDex commented on GitHub (Nov 20, 2021): @catthehacker any chance of this being fixed via the changes @ChristopherHX made being implemented into the this branch? What is needed for this to be fixed/tested further?
Author
Owner

@catthehacker commented on GitHub (Nov 20, 2021):

What is needed for this to be fixed/tested further?

Pull request.

<!-- gh-comment-id:974636119 --> @catthehacker commented on GitHub (Nov 20, 2021): > What is needed for this to be fixed/tested further? Pull request.
Author
Owner

@BlackDex commented on GitHub (Nov 20, 2021):

@catthehacker ok, PR created.
I tested this on my own workflow files, and it seems to work.
The make test isn't working for me on the master branch so i can't really test it using the go-tests locally for some reason on my PR either.

<!-- gh-comment-id:974648658 --> @BlackDex commented on GitHub (Nov 20, 2021): @catthehacker ok, PR created. I tested this on my own workflow files, and it seems to work. The `make test` isn't working for me on the master branch so i can't really test it using the go-tests locally for some reason on my PR either.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#478
No description provided.