Remove environment variable from job

Blatant copy-paste from How to remove an environment variable on GitHub actions? - Stack Overflow.

Context

On Environment variables - GitHub Docs
they describe a way to add an environment variable with yaml:

jobs:
  job_name:
    env:
      NAME: value

On https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions/#setting-an-environment-variable linked from the same place, shows how to add an environment variable from script steps:

echo "NAME=value" >> $GITHUB_ENV

Question

I’m looking for a way to do the opposite: given that an env var was added with one of the above options, fully remove it so that subsequent job steps don’t see it either.

I tried

echo "NAME=" >> $GITHUB_ENV

but it just sets it to empty string, I need it gone so that env doesn’t list it any more.

1 Like

My answer from another thread with a very similar question fits here, too:

Sadly that doesn’t help because a uses creates the env var, not me.

It’s a workaround, not a solution. Is there a tracking issue I could vote on or follow to add this?

1 Like