Only set env vars if they are unset.

This commit is contained in:
Jonas Bushart 2023-02-13 20:44:18 +01:00
parent dfa8744db3
commit 045ad9ff3f
2 changed files with 23 additions and 6 deletions

View file

@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
* Only set environment variables, if they are not set before.
This allows setting environment variables before using this action and keeping their values.
## [1.3.7] - 2023-01-31 ## [1.3.7] - 2023-01-31
### Fixed ### Fixed

View file

@ -57,15 +57,27 @@ runs:
# The environment variables always need to be set before the caching action # The environment variables always need to be set before the caching action
- name: "Setting Environment Variables" - name: "Setting Environment Variables"
run: | run: |
if [[ ! -v CARGO_INCREMENTAL ]]; then
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
fi
if [[ ! -v CARGO_PROFILE_DEV_DEBUG ]]; then
echo "CARGO_PROFILE_DEV_DEBUG=0" >> $GITHUB_ENV echo "CARGO_PROFILE_DEV_DEBUG=0" >> $GITHUB_ENV
fi
if [[ ! -v CARGO_TERM_COLOR ]]; then
echo "CARGO_TERM_COLOR=always" >> $GITHUB_ENV echo "CARGO_TERM_COLOR=always" >> $GITHUB_ENV
fi
if [[ ! -v RUST_BACKTRACE ]]; then
echo "RUST_BACKTRACE=short" >> $GITHUB_ENV echo "RUST_BACKTRACE=short" >> $GITHUB_ENV
fi
if [[ ! -v RUSTFLAGS ]]; then
echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
fi
# Enable faster sparse index on nightly # Enable faster sparse index on nightly
# The value is ignored on stable and causes no problems # The value is ignored on stable and causes no problems
# https://internals.rust-lang.org/t/call-for-testing-cargo-sparse-registry/16862 # https://internals.rust-lang.org/t/call-for-testing-cargo-sparse-registry/16862
if [[ ! -v CARGO_UNSTABLE_SPARSE_REGISTRY ]]; then
echo "CARGO_UNSTABLE_SPARSE_REGISTRY=true" >> $GITHUB_ENV echo "CARGO_UNSTABLE_SPARSE_REGISTRY=true" >> $GITHUB_ENV
fi
# Enable sparse index after stabilization # Enable sparse index after stabilization
# This causes warnings on stable 1.67, e.g., when using "cargo add" # This causes warnings on stable 1.67, e.g., when using "cargo add"
# https://github.com/rust-lang/cargo/pull/11224 # https://github.com/rust-lang/cargo/pull/11224