actions / actions/runner

function in runs-on doesn't work

Open
#780 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Runner Bug
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

Describe the bug

I have the workflow listen on event deployment for app deployment.
I'd like to reuse the same workflow for both nonprod and prod.
that means i have to use variable as runner label in runs-on statement.
however, runs-on doesn't support func call:
Not work
runs-on: ["${{ fromJson(github.event.deployment.payload).runnerLabel }}"] results in runs-on: [""]
Work
runs-on: ["${{ github.event.deployment.description }}"] results in runs-on: ["prod"]
assume description has the right runner label value

To Reproduce
Steps to reproduce the behavior:

name: CD

on: ['deployment']

jobs:
  deploy:
    name: Deploy
    runs-on: ["${{ fromJson(github.event.deployment.payload).runnerLabel }}"]
    steps:
      ...

the workflow failed says no runner matched. "${{ fromJson(github.event.deployment.payload).runnerLabel }}" results in an empty string.

Expected behavior
expect the value being correctly extracted from json, like runs-on: ["prod"]

Runner Version and Platform

Version of your runner?

2.273.5

OS of the machine running the runner? OSX/Windows/Linux/...

Ubuntu 20.04

What's not working?

Please include error messages and screenshots.

Job Log Output

N/A

Runner and Worker's Diagnostic Logs

N/A

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the deployment-triggered workflow from the issue using runner version 2.273.5 and compare the fromJson expression with the direct description value in runs-on. Trace the runner's workflow-expression handling to determine why runnerLabel becomes empty; done when the JSON value resolves to a runner label and the job selects the expected runner.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions
Domain
ci-cd
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.