Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call a reusable workflow in github actions and pass a value to its predefined input param

My workflow:

name: test

on:
  workflow_call:
    inputs:
      env:
        description: 'Test'
        default: 'stage'
        required: true
        type: string

From docs reusable workflows:

jobs:
  call-workflow-passing-data:
    uses: octo-org/example-repo/.github/workflows/reusable-workflow.yml@main
    with:
      config-path: .github/labeler.yml
    secrets:
      envPAT: ${{ secrets.envPAT }}

But I dont understand where do I pass my "env" input variable when i call the workflow in a different workflow? would it be considered a secret? So I just gotta do

        secrets:
           env: "someEnv"

Is it like this?

Or should I modify this:

    with:
      config-path: .github/labeler.yml

To this:

    with:
      env: "abc"
like image 740
gabriel munteanu Avatar asked Oct 23 '25 07:10

gabriel munteanu


1 Answers

As stated in the link you shared, there are two different types of inputs you can customize in reusable workflows: The inputs field, and the secrets field.

Example with the inputs field:

name: example1

on:
  workflow_call:
    inputs:
      env:
        description: 'Test'
        default: 'stage'
        required: true
        type: string

This workflow will be called by using:

jobs:
  example1:
    uses: <ORG>/<REPO>/.github/workflows/reusable-workflow.yml@main
    with:
      env: 'ENV_VALUE'

Example with the secrets field:

name: example2

on:
  workflow_call:
    secrets:
      env:
        description: 'Test'
        required: true

This workflow will be called by using:

jobs:
  example2:
    uses: <ORG>/<REPO>/.github/workflows/reusable-workflow.yml@main
    secrets:
      env: ${{ secrets.SECRET_NAME }}

Example with both inputs and secrets field:

name: example3

on:
  workflow_call:
    inputs:
      env:
        description: 'Test'
        default: 'stage'
        required: true
        type: string
    secrets:
      env:
        description: 'Test'
        required: true

This workflow will be called by using:

jobs:
  example3:
    uses: <ORG>/<REPO>/.github/workflows/reusable-workflow.yml@main
    with:
      env: 'ENV_VALUE'
    secrets:
      env: ${{ secrets.SECRET_NAME }}
like image 104
GuiFalourd Avatar answered Oct 25 '25 08:10

GuiFalourd