Skip to content

Commit c55d305

Browse files
author
Aliaksandr Adziareika
committed
Fix distro detect step to work in a container
1 parent 450f204 commit c55d305

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

.github/actions/ccache-setup/action.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,26 @@ runs:
8585
DISTRO="windows"
8686
VERSION="nt$(powershell -Command "[System.Environment]::OSVersion.Version.Major")"
8787
else
88-
DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
89-
VERSION=$(lsb_release -rs)
88+
# Try lsb_release first, then fall back to /etc/os-release or /etc/redhat-release
89+
if command -v lsb_release &> /dev/null; then
90+
echo "Reading distro info from lsb_release"
91+
DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
92+
VERSION=$(lsb_release -rs)
93+
elif [ -f /etc/os-release ]; then
94+
echo "Reading distro info from /etc/os-release"
95+
DISTRO=$(. /etc/os-release && echo "$ID")
96+
VERSION=$(. /etc/os-release && echo "$VERSION_ID")
97+
elif [ -f /etc/redhat-release ]; then
98+
echo "Reading distro info from /etc/redhat-release"
99+
DISTRO="rhel"
100+
VERSION=$(grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release | head -1)
101+
else
102+
echo "Could not detect distro, using fallback"
103+
DISTRO="linux"
104+
VERSION="unknown"
105+
fi
90106
fi
107+
echo "Detected: DISTRO=$DISTRO, VERSION=$VERSION"
91108
echo "distro=${DISTRO}-${VERSION}" >> "$GITHUB_OUTPUT"
92109
93110
# Get architecture (e.g., x86-64, arm64, x86-32)

0 commit comments

Comments
 (0)