actions / toolkit

The GitHub ToolKit for developing GitHub Actions.
https://github.com/features/actions
MIT License
5.02k stars 1.45k forks source link

Access runner.name #1681

Open AnHeuermann opened 8 months ago

AnHeuermann commented 8 months ago

Description

I want to access the name of the runner executing an action. From runner-context I want to access:

For runner.os and runner.arch I can implement alternatives, but I couldn't find a way to get runner.name.

My motivation is to give artifacts unique names that are recognizable by adding the runner name to them.

Code Snipped

So for a JavaScript / TypeScript action my-action running from workflow

jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}

    steps:
      - uses: username/my-action

I want to get "ubuntu-latest" and "windows-latest".

const core = require('@actions/core');

console.log(core.runner.name) // "ubuntu-latest"
console.log(core.runner.os)  // "Ubuntu 22.04.3 LTS" or similar
console.log(core.runner.arch)  // "x64"

Additional information

Similar to https://github.com/actions/toolkit/issues/599, but I only need runner context information. Similar to capabilities documented in https://github.com/actions/toolkit/tree/main/packages/core#platform-helper, but that one isn't defined: https://github.com/actions/toolkit/issues/1630.

Versions 'n' stuff