[GH-ISSUE #384] Support for $GITHUB_ENV #268

Closed
opened 2026-03-01 21:41:55 +03:00 by kerem · 14 comments
Owner

Originally created by @haizaar on GitHub (Oct 7, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/384

Good day,
First, thank you for writing this tool - AFAIK it's the only local simulator for any CI out there.

To the topic - GH seem to have moved to a new way to define env vars [1]:

echo "action_state=yellow" >> $GITHUB_ENV

However it doesn't seem to be supported by act. Specifying the following in the workflow file:

- name: Set CI instance ID                                                                                               
  run: |                                                                                                                 
    echo GITHUB_ENV=$GITHUB_ENV                                                                                          
    echo 'CI_INSTANCE_ID="-ci${{ github.run_id }}"' >> $GITHUB_ENV  

fails with:

| GITHUB_ENV=
| /github/workflow/1: line 3: $GITHUB_ENV: ambiguous redirect

Can you please support it?

[1] https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable

Originally created by @haizaar on GitHub (Oct 7, 2020). Original GitHub issue: https://github.com/nektos/act/issues/384 Good day, First, thank you for writing this tool - AFAIK it's the only local simulator for any CI out there. To the topic - GH seem to have moved to a new way to define env vars [1]: ```shell echo "action_state=yellow" >> $GITHUB_ENV ``` However it doesn't seem to be supported by act. Specifying the following in the workflow file: ```yaml - name: Set CI instance ID run: | echo GITHUB_ENV=$GITHUB_ENV echo 'CI_INSTANCE_ID="-ci${{ github.run_id }}"' >> $GITHUB_ENV ``` fails with: ``` | GITHUB_ENV= | /github/workflow/1: line 3: $GITHUB_ENV: ambiguous redirect ``` Can you please support it? [1] https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
kerem closed this issue 2026-03-01 21:41:55 +03:00
Author
Owner

@haizaar commented on GitHub (Oct 7, 2020):

Using the set-env command also results in a deprecation warning:

The `set-env` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
<!-- gh-comment-id:704704496 --> @haizaar commented on GitHub (Oct 7, 2020): Using the `set-env` command also results in a deprecation warning: ``` The `set-env` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/ ```
Author
Owner

@fd0 commented on GitHub (Oct 11, 2020):

Thank you very much for this great tool! This issue also applies to the add-path command (e.g. via echo ::add-path).

<!-- gh-comment-id:706675931 --> @fd0 commented on GitHub (Oct 11, 2020): Thank you very much for this great tool! This issue also applies to the `add-path` command (e.g. via `echo ::add-path`).
Author
Owner

@Jaesin commented on GitHub (Oct 22, 2020):

Another common use is writing to $GITHUB_PATH. i.e. echo "$(composer config -g home)/vendor/bin" >> $GITHUB_PATH so the path persists in subsequent run steps. $GITHUB_PATH would be a file that would get parsed for paths on every run command. I remember doing something like this manually with travisci a while back so it would be really nice to have this working.

<!-- gh-comment-id:714719153 --> @Jaesin commented on GitHub (Oct 22, 2020): Another common use is writing to `$GITHUB_PATH`. i.e. `echo "$(composer config -g home)/vendor/bin" >> $GITHUB_PATH` so the path persists in subsequent run steps. `$GITHUB_PATH` would be a file that would get parsed for paths on every run command. I remember doing something like this manually with travisci a while back so it would be really nice to have this working.
Author
Owner

@Risto-Stevcev commented on GitHub (Nov 11, 2020):

Any updates on this?

<!-- gh-comment-id:725379308 --> @Risto-Stevcev commented on GitHub (Nov 11, 2020): Any updates on this?
Author
Owner

@torbjornvatn commented on GitHub (Nov 11, 2020):

I've gave this a go yesterday, not completely done yet though.
I'll report back when I get it working.

<!-- gh-comment-id:725604487 --> @torbjornvatn commented on GitHub (Nov 11, 2020): I've gave this a go yesterday, not completely done yet though. I'll report back when I get it working.
Author
Owner

@haizaar commented on GitHub (Nov 17, 2020):

set-env & friends commands are now disabled by default, i.e. warnings became errors.
Now need to set ACTIONS_ALLOW_UNSECURE_COMMANDS to make it still work.

<!-- gh-comment-id:728641189 --> @haizaar commented on GitHub (Nov 17, 2020): `set-env` & friends commands are now disabled by default, i.e. warnings became errors. Now need to set `ACTIONS_ALLOW_UNSECURE_COMMANDS` to make it still work.
Author
Owner

@torbjornvatn commented on GitHub (Nov 18, 2020):

@haizaar I'll see if I manage to wrap up my PR on this today

<!-- gh-comment-id:729505086 --> @torbjornvatn commented on GitHub (Nov 18, 2020): @haizaar I'll see if I manage to wrap up my PR on this today
Author
Owner

@torbjornvatn commented on GitHub (Nov 20, 2020):

I have something working now. Just have to do some clean up and testing tomorrow

<!-- gh-comment-id:730727985 --> @torbjornvatn commented on GitHub (Nov 20, 2020): I have something working now. Just have to do some clean up and testing tomorrow
Author
Owner

@haizaar commented on GitHub (Nov 20, 2020):

@torbjornvatn If you have a build to test, let me know.

<!-- gh-comment-id:730794754 --> @haizaar commented on GitHub (Nov 20, 2020): @torbjornvatn If you have a build to test, let me know.
Author
Owner

@kimtore commented on GitHub (Nov 30, 2020):

Any updates here?

<!-- gh-comment-id:735677691 --> @kimtore commented on GitHub (Nov 30, 2020): Any updates here?
Author
Owner

@torbjornvatn commented on GitHub (Dec 1, 2020):

#426 is being reviewed by @cplee

<!-- gh-comment-id:736315759 --> @torbjornvatn commented on GitHub (Dec 1, 2020): #426 is being reviewed by @cplee
Author
Owner

@Sultanyaron commented on GitHub (Jan 24, 2023):

@torbjornvatn Hi, I am still getting an error when trying to set $GITHUB_ENV

Maybe you can assist here:

echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE -w packages/${{ github.event.inputs.packageName }})" >> $GITHUB_ENV

The error i am getting is: Error: Error occurred running finally: Error occurred running finally: Error occurred running finally: Error occurred running finally: Error occurred running finally: Error occurred running finally: invalid format 'v0.1.0', expected a line with '=' or '<<' (original error: <nil>) (original error: <nil>) (original error: <nil>) (original error: <nil>) (original error: <nil>) (original error: <nil>)

<!-- gh-comment-id:1402277298 --> @Sultanyaron commented on GitHub (Jan 24, 2023): @torbjornvatn Hi, I am still getting an error when trying to set $GITHUB_ENV Maybe you can assist here: ```yml echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE -w packages/${{ github.event.inputs.packageName }})" >> $GITHUB_ENV ``` The error i am getting is: `Error: Error occurred running finally: Error occurred running finally: Error occurred running finally: Error occurred running finally: Error occurred running finally: Error occurred running finally: invalid format 'v0.1.0', expected a line with '=' or '<<' (original error: <nil>) (original error: <nil>) (original error: <nil>) (original error: <nil>) (original error: <nil>) (original error: <nil>)`
Author
Owner

@torbjornvatn commented on GitHub (Jan 25, 2023):

Sorry @Sultanyaron, it's been so long since I looked at Act. So the implementation for this has likely changed several times since I was involved.
So I would encourage you to open a new issue and reference this one

<!-- gh-comment-id:1403108945 --> @torbjornvatn commented on GitHub (Jan 25, 2023): Sorry @Sultanyaron, it's been so long since I looked at Act. So the implementation for this has likely changed several times since I was involved. So I would encourage you to open a new issue and reference this one
Author
Owner

@ChristopherHX commented on GitHub (Jan 25, 2023):

@Sultanyaron Are you writing the correct format?
The parser probably found something like this, which has a format error on line 2.

NEW_VERSION=
v0.1.0

Use cat "$GITHUB_ENV" to verify if your format is correct. Docs: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable

<!-- gh-comment-id:1403272928 --> @ChristopherHX commented on GitHub (Jan 25, 2023): @Sultanyaron Are you writing the correct format? The parser probably found something like this, which has a format error on line 2. ``` NEW_VERSION= v0.1.0 ``` Use `cat "$GITHUB_ENV"` to verify if your format is correct. Docs: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
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#268
No description provided.