Dynamically add inputs to Action

Is there any way to dynamically add inputs to an Action? Or for the Action itself to access the environment variables defined in the workflow that it is being called from? I would like to use the same Action which requires different environment variables per app that I’m using them on, so I can’t define them all as inputs.

@jswny,

You can try using the workflow command “set-env” to create or update an environment variable for any steps running next in a job. All the subsequent steps in the same job have access to the new value.
A simple demo:

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    env:
      MY_ENV: "env value 01"
    steps:
      - name: run action - 1st
        uses: actionOrg/actionRepo@master
        with:
          input: ${{ env.MY_ENV }}  # the input value is "env value 01"

      - name: update env
        run: echo "::set-env name=MY_ENV::env value 02"

      - name: run action - 2nd
        uses: actionOrg/actionRepo@master
        with:
          input: ${{ env.MY_ENV }}  # the input value is "env value 02"

when using the set-env command, you also can call the value of another variable to set the new value of the environment variable.
For example:

- name: update env
  run: |
    number=02
    echo "::set-env name=MY_ENV::env value $number"
   # the new value is "env value 02"