Skip to content

Commit 9b4dfb0

Browse files
committed
✨ Pre-install Python if there's none
This is not usually the case for GitHub-hosted Runners but it might happen with self-hosted runners. Fixes #289.
1 parent 0a87186 commit 9b4dfb0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

action.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,26 @@ runs:
130130
PR_REF: ${{ github.event.pull_request.head.ref }}
131131
PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
132132
PR_REPO_ID: ${{ github.event.pull_request.base.repo.id }}
133+
- name: Discover pre-installed Python
134+
id: pre-installed-python
135+
run: |
136+
# 🔎 Discover pre-installed Python
137+
echo "python-path=$(command -v python3 || :)" | tee -a "${GITHUB_OUTPUT}"
138+
shell: bash
139+
- name: Install Python 3
140+
if: steps.pre-installed-python.outputs.python-path == ''
141+
id: new-python
142+
uses: actions/setup-python@v5
143+
with:
144+
python-version: 3.x
133145
- name: Create Docker container action
134146
run: |
135147
# Create Docker container action
136-
python ${{ github.action_path }}/create-docker-action.py
148+
${{
149+
steps.pre-installed-python.outputs.python-path == ''
150+
&& steps.new-python.outputs.python-path
151+
|| steps.pre-installed-python.outputs.python-path
152+
}} '${{ github.action_path }}/create-docker-action.py'
137153
env:
138154
REF: ${{ steps.set-repo-and-ref.outputs.ref }}
139155
REPO: ${{ steps.set-repo-and-ref.outputs.repo }}

0 commit comments

Comments
 (0)