You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/23 08:08:56 UTC
(mynewt-core) 03/03: ci: Remove toolchain only if installed in home directory
This is an automated email from the ASF dual-hosted git repository.
sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 11b28c06f28da73ca0847dde2641663d8ce821f8
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Thu Oct 22 19:07:59 2026 +0200
ci: Remove toolchain only if installed in home directory
Toolchain directory to remove was derived from toolchain path by
stripping $HOME prefix and taking first path component. If toolchain
were ever installed outside home directory (e.g. in tool cache) that
component would be empty and whole home directory, including
workspace, would be removed. Remove directory only if toolchain path
is inside home directory and only warn otherwise.
Assisted-by: Claude:claude-opus-5-5
---
.github/actions/gcc-target-build/action.yml | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/.github/actions/gcc-target-build/action.yml b/.github/actions/gcc-target-build/action.yml
index f1527eb6c..cd1e208e6 100644
--- a/.github/actions/gcc-target-build/action.yml
+++ b/.github/actions/gcc-target-build/action.yml
@@ -61,6 +61,14 @@ runs:
env:
GCC_PATH: ${{ steps.gcc.outputs.path }}
run: |
- # Toolchain is installed in directory in home directory
- dir="${GCC_PATH#"$HOME"/}"
- rm -rf "$HOME/${dir%%/*}"
+ # Toolchain is installed in directory in home directory, never
+ # remove anything if it is elsewhere (it would remove $HOME).
+ case "$GCC_PATH" in
+ "$HOME"/[!/]*)
+ dir="${GCC_PATH#"$HOME"/}"
+ rm -rf "${HOME:?}/${dir%%/*}"
+ ;;
+ *)
+ echo "::warning::Toolchain not in $HOME, not removed: $GCC_PATH"
+ ;;
+ esac