From 9b4dfb0c84502497080469ffeb5e75f9c5cce5c2 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Wed, 6 Nov 2024 16:13:48 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Pre-install=20Python=20if=20there's?= =?UTF-8?q?=20none?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not usually the case for GitHub-hosted Runners but it might happen with self-hosted runners. Fixes #289. --- action.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index f4dea68..3e39fd1 100644 --- a/action.yml +++ b/action.yml @@ -130,10 +130,26 @@ runs: PR_REF: ${{ github.event.pull_request.head.ref }} PR_REPO: ${{ github.event.pull_request.head.repo.full_name }} PR_REPO_ID: ${{ github.event.pull_request.base.repo.id }} + - name: Discover pre-installed Python + id: pre-installed-python + run: | + # 🔎 Discover pre-installed Python + echo "python-path=$(command -v python3 || :)" | tee -a "${GITHUB_OUTPUT}" + shell: bash + - name: Install Python 3 + if: steps.pre-installed-python.outputs.python-path == '' + id: new-python + uses: actions/setup-python@v5 + with: + python-version: 3.x - name: Create Docker container action run: | # Create Docker container action - python ${{ github.action_path }}/create-docker-action.py + ${{ + steps.pre-installed-python.outputs.python-path == '' + && steps.new-python.outputs.python-path + || steps.pre-installed-python.outputs.python-path + }} '${{ github.action_path }}/create-docker-action.py' env: REF: ${{ steps.set-repo-and-ref.outputs.ref }} REPO: ${{ steps.set-repo-and-ref.outputs.repo }}