Is it possible to detect which OS a Github actions runner is using? For example, in node one can run process.platform
to get the OS. Is there something analogous inside of Github actions?
CodePudding user response:
There is an environment variable $RUNNER_OS
containing the operating system; you can specify the shell for a run:
independent of the runner operating system, i.e., you can use Bash everywhere.
For example, this workflow
name: OS test
on:
workflow_dispatch:
jobs:
printos:
name: Print OS name for each OS
strategy:
matrix:
os:
- ubuntu-20.04
- windows-2022
- macos-11
runs-on: ${{ matrix.os }}
steps:
- name: Print OS name
shell: bash
run: |
echo "$RUNNER_OS"
produces three jobs, with outputs Linux
, Windows
, and macOS
, respectively.