Replies: 4 comments 1 reply
-
|
Currently, Github actions does n't provide a direct way to unset environment variable using
echo "MY_VAR=" >> $GITHUB_ENV
- run: unset MY_VAR
shell: bashor, Conditionally set variables based on your needs... now see, Why thats matters:cause
Btw, So, for now the best approach depends on your specific use case and whether you need the variable completely absent or just empty...
|
Beta Was this translation helpful? Give feedback.
-
|
Currently, GitHub Actions does not support fully unsetting an environment variable via GITHUB_ENV. Writing an empty string clears its value but the variable still exists. Workarounds: Set it empty in GITHUB_ENV: echo "MY_VAR=" >> $GITHUB_ENV Or unset in a shell step: unset MY_VAR Until GitHub adds native support, using unset in shell is the most reliable way to remove a variable. |
Beta Was this translation helpful? Give feedback.
-
|
As others have noted, using echo "MY_VAR=" >> $GITHUB_ENV only sets the variable to an empty string, it doesn't actually unset the variable (meaning it still exists, but is empty). The most reliable way to truly unset an environment variable so that it's completely removed from the environment is to use the shell command unset within a specific step: Key Takeaway
Using unset MY_VAR is the way to completely remove the variable from the environment for the remainder of that specific step. Unfortunately, there's no native way to use GITHUB_ENV to completely unset a variable for all subsequent steps at this time, though the GitHub Actions team has acknowledged this limitation. |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Why are you starting this discussion?
Question
What GitHub Actions topic or product is this about?
Misc
Discussion Details
Is there a way to actually unset an environment variable (distinct from setting it to an empty string) using
GITHUB_ENV? The documentation only shows how to set it.Beta Was this translation helpful? Give feedback.
All reactions