From 01a89c6f369b732a9add6c98e5951ac44c9c3516 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 17 Oct 2023 20:49:25 -0400 Subject: [PATCH] Show conditional enabling of caching It took me a while to figure out how to use caching system on a condition, and set the relevant env vars. Initially, I thought those env vars had to be set on the caching action itself, not on all the other actions -- this should be clarified too --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index f01cbb9..4e90dcf 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,19 @@ Just copy and paste the following in your GitHub action: uses: mozilla-actions/sccache-action@v0.0.3 ``` +### Conditionally run cache and enable it + +``` +- name: Run sccache-cache only on non-release runs + if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' + uses: mozilla-actions/sccache-action@v0.0.3 +- name: Set Rust caching env vars only on non-release runs + if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' + run: | + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV +``` + ### Specify a given version of sccache ```