Skip to content
Latchkey

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: python runs the file with the Python currently on PATH; set up the version first if it matters.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →