Skip to content

Commit 045ad9f

Browse files
committed
Only set env vars if they are unset.
1 parent dfa8744 commit 045ad9f

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
* Only set environment variables, if they are not set before.
13+
This allows setting environment variables before using this action and keeping their values.
14+
1015
## [1.3.7] - 2023-01-31
1116

1217
### Fixed

action.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,27 @@ runs:
5757
# The environment variables always need to be set before the caching action
5858
- name: "Setting Environment Variables"
5959
run: |
60-
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
61-
echo "CARGO_PROFILE_DEV_DEBUG=0" >> $GITHUB_ENV
62-
echo "CARGO_TERM_COLOR=always" >> $GITHUB_ENV
63-
echo "RUST_BACKTRACE=short" >> $GITHUB_ENV
64-
echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
60+
if [[ ! -v CARGO_INCREMENTAL ]]; then
61+
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
62+
fi
63+
if [[ ! -v CARGO_PROFILE_DEV_DEBUG ]]; then
64+
echo "CARGO_PROFILE_DEV_DEBUG=0" >> $GITHUB_ENV
65+
fi
66+
if [[ ! -v CARGO_TERM_COLOR ]]; then
67+
echo "CARGO_TERM_COLOR=always" >> $GITHUB_ENV
68+
fi
69+
if [[ ! -v RUST_BACKTRACE ]]; then
70+
echo "RUST_BACKTRACE=short" >> $GITHUB_ENV
71+
fi
72+
if [[ ! -v RUSTFLAGS ]]; then
73+
echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
74+
fi
6575
# Enable faster sparse index on nightly
6676
# The value is ignored on stable and causes no problems
6777
# https://internals.rust-lang.org/t/call-for-testing-cargo-sparse-registry/16862
68-
echo "CARGO_UNSTABLE_SPARSE_REGISTRY=true" >> $GITHUB_ENV
78+
if [[ ! -v CARGO_UNSTABLE_SPARSE_REGISTRY ]]; then
79+
echo "CARGO_UNSTABLE_SPARSE_REGISTRY=true" >> $GITHUB_ENV
80+
fi
6981
# Enable sparse index after stabilization
7082
# This causes warnings on stable 1.67, e.g., when using "cargo add"
7183
# https://github.com/rust-lang/cargo/pull/11224

0 commit comments

Comments
 (0)