How to Run a Script With a Specific Interpreter in GitHub Actions
The step-level shell: key selects which interpreter runs your script, from bash and pwsh to python or a custom command template.
Set shell: on the step to bash, sh, pwsh, python, or a custom template with {0}. This lets one workflow mix shell and Python inline scripts cleanly.
Steps
- Add
shell:to the step naming the interpreter. - For inline Python use
shell: python. - For a custom interpreter, use a template such as
shell: perl {0}.
Workflow
.github/workflows/ci.yml
steps:
- name: Inline Python
shell: python
run: |
import platform
print("Running on", platform.system())
- name: PowerShell step
shell: pwsh
run: Write-Host "Hello from pwsh"Gotchas
- The custom template must include
{0}, which GitHub replaces with the script file path. shell: pythonruns the file with the Python currently on PATH; set up the version first if it matters.
Related guides
How to Run a Python Script in GitHub ActionsRun a Python script in GitHub Actions by setting up Python with actions/setup-python, installing dependencies…
How to Run a Script Only on One OS in GitHub ActionsRun a GitHub Actions script on just one operating system in a matrix build with a step-level if on runner.os,…