如何动态分配 github 操作中的运行值

Wik*_*iki 5 github-actions github-actions-self-hosted-runners

name: test if conditions
name: test if conditions
on:
  push:
    branches: [master, test]
env:
  TEST_BRANCH: "test"
  EMPTY_VALUE: ""
jobs:
  test-conditions:
    runs-on: ubuntu-latest
    steps:
      - name: simple evaluation on test
        run: echo "runs"
Run Code Online (Sandbox Code Playgroud)
#eg) for test branch => runs-on: ubuntu-latest
     for master branch => runs-on: ['self-hosted', 'products', 'latest']
Run Code Online (Sandbox Code Playgroud)

是否可以在同一工作流程中动态加载运行?

Wik*_*iki 3

${{ (inputs.shouldUseSelfHosted) && fromJSON('[ "self-hosted", "Linux", "X64" ]') || 'ubuntu-latest' }}
Run Code Online (Sandbox Code Playgroud)

参考: https: //github.com/actions/runner/issues/409