EnvironmentFileOverwritten
¶
Environment files should be appended.
Defined by EnvironmentFileOverwriteRule
which supports workflows, actions in the "Default" ruleset.
Description¶
Most environment files are used to pass data between steps, and should be appended to, not overwritten.
It is a common mistake to overwrite environment files, which can lead to data loss or unexpected behavior.
Use >>
instead of >
, to ensure the file is appended, not overwritten.
References:
Compliant example¶
Appending to an environment file is usually the intended behavior.
example.yml
on: push jobs: example: runs-on: ubuntu-latest steps: - run: echo "result=Example" >> $GITHUB_OUTPUT
Non-compliant example¶
Overwriting an environment file is probably unintended.
example.yml
on: push jobs: example: runs-on: ubuntu-latest steps: - run: echo "result=Example" > $GITHUB_OUTPUT
- Line 6: Step[#0] in Job[example] overwrites environment file
GITHUB_OUTPUT
.