From 045ad9ff3f7ce6f0b555fcbeb32574fd8927a5af Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Mon, 13 Feb 2023 20:44:18 +0100 Subject: [PATCH] Only set env vars if they are unset. --- CHANGELOG.md | 5 +++++ action.yml | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 378b373..941ccf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [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 ### Fixed diff --git a/action.yml b/action.yml index 1ad2ed4..b96a000 100644 --- a/action.yml +++ b/action.yml @@ -57,15 +57,27 @@ runs: # The environment variables always need to be set before the caching action - name: "Setting Environment Variables" run: | - echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV - echo "CARGO_PROFILE_DEV_DEBUG=0" >> $GITHUB_ENV - echo "CARGO_TERM_COLOR=always" >> $GITHUB_ENV - echo "RUST_BACKTRACE=short" >> $GITHUB_ENV - echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV + if [[ ! -v CARGO_INCREMENTAL ]]; then + echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV + fi + if [[ ! -v CARGO_PROFILE_DEV_DEBUG ]]; then + echo "CARGO_PROFILE_DEV_DEBUG=0" >> $GITHUB_ENV + fi + if [[ ! -v CARGO_TERM_COLOR ]]; then + echo "CARGO_TERM_COLOR=always" >> $GITHUB_ENV + fi + if [[ ! -v RUST_BACKTRACE ]]; then + echo "RUST_BACKTRACE=short" >> $GITHUB_ENV + fi + if [[ ! -v RUSTFLAGS ]]; then + echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV + fi # Enable faster sparse index on nightly # The value is ignored on stable and causes no problems # https://internals.rust-lang.org/t/call-for-testing-cargo-sparse-registry/16862 - echo "CARGO_UNSTABLE_SPARSE_REGISTRY=true" >> $GITHUB_ENV + if [[ ! -v CARGO_UNSTABLE_SPARSE_REGISTRY ]]; then + echo "CARGO_UNSTABLE_SPARSE_REGISTRY=true" >> $GITHUB_ENV + fi # Enable sparse index after stabilization # This causes warnings on stable 1.67, e.g., when using "cargo add" # https://github.com/rust-lang/cargo/pull/11224