Github actions/github-script not printing input

I have the following reusable

on:
  workflow_call:
    inputs:
      base_os:
        description: "The base os"
        type: string
        required: true


jobs:
  upstream-image-name:
    name: get the image name for the upstream image
    runs-on: ubuntu-latest

    steps:

      - name: get upstream image name
        id: upstream-image-name-step
        uses: actions/github-script@v6
        with:
          result-encoding: string
          script:
            console.log('base_os =', core.getInput('base_os'))

I am invoking it as follows

on:
  push:
    branches:
      - reusable-runtime

jobs:
  invoke-reusable:
    name: test invocation of reusable
    uses: Repo/Owner/.github/workflows/reusable_runtime.yaml@reusable-runtime
    with:
      base_os: debian

The logs

Run actions/github-script@v6
base_os = 

What am I missing?

>Solution :

The core.getInput will not take directly inputs from the workflow inputs. You need to pass it through like this:

on:
  workflow_call:
    inputs:
      base_os:
        description: "The base os"
        type: string
        required: true


jobs:
  upstream-image-name:
    name: get the image name for the upstream image
    runs-on: ubuntu-latest

    steps:

      - name: get upstream image name
        id: upstream-image-name-step
        uses: actions/github-script@v6
        with:
          result-encoding: string
          base_os: ${{ inputs.base_os }}
          script:
            console.log('base_os =', core.getInput('base_os'))

Leave a Reply