Skip to content

Commit 9c67bdc

Browse files
committed
fix for python install on self-hosted runners
1 parent b3bbdd4 commit 9c67bdc

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

.github/workflows/reusable_codeql.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,27 @@ jobs:
3434
with:
3535
fetch-depth: 0
3636

37-
- name: Setup newer Python
37+
- name: Check for Python >= 3.10
38+
id: check_python
39+
run: |
40+
echo "python_exists=false" >> $GITHUB_OUTPUT
41+
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
42+
if ($pythonCommand) {
43+
$pythonVersion = python --version 2>&1
44+
$versionPattern = 'Python (\d+)\.(\d+)\.(\d+)'
45+
echo $pythonVersion
46+
if ($pythonVersion -match $versionPattern) {
47+
$major = [int]$matches[1]
48+
$minor = [int]$matches[2]
49+
if ($major -gt 3 -or ($major -eq 3 -and $minor -ge 10)) {
50+
echo "python_exists=true" >> $GITHUB_OUTPUT
51+
}
52+
}
53+
}
54+
shell: pwsh
55+
56+
- name: Setup Python 3.10
57+
if: steps.check_python.outputs.python_exists == 'false'
3858
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
3959
with:
4060
python-version: "3.10"

0 commit comments

Comments
 (0)