question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

INPUT_* environment variables are missing in composite actions

See original GitHub issue

According to the documentation actions should receive their input values as environment variables prefixed with INPUT_ in addition to the inputs context. These environment variables are missing for composite actions.

To Reproduce Steps to reproduce the behavior:

  1. Create a composite action with one or more inputs, and a step that outputs the associated INPUT variables:
inputs:
  foo:
    description: 'Test input'
    required: yes
runs:
  using: composite
  steps:
    - run: |
        echo "FOO: ${INPUT_FOO}"
      shell: bash
  1. Use the action in a workflow:
steps:
  - uses: ./example-action
    with:
      foo: 'bar'
  1. Observe the lack of value after the FOO: prefix.

I have an example action and workflow (the uses: ./composite-action step) that demonstrate the issue and the obvious workaround. There’s a workflow run as well (check the “Run /./composite-action” step).

Expected behavior Steps should be able to read inputs via environment variables, INPUT_FOO in the example above, INPUT_NUM1 (to 4) in my reproducer.

Runner Version and Platform

Version of your runner?

  • 2.272.0

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

  • Ubuntu 20.04.1 LTS (Github hosted runner VM)

Job Log Output

From the workflow run linked above:

Run ./composite-action
  with:
    num1: 1
    num2: 4
    num3: 0
    num4: 0
Show INPUT vars
  INPUT_NUM1 = 
  INPUT_NUM2 = 
  INPUT_NUM3 = 
  INPUT_NUM4 = 
Add numbers

Credit

I became aware of the issue thanks to a post on the Github community forum and tried to reproduce the issue out of curiosity.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:50
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

27reactions
ericsciplecommented, Aug 19, 2020

When authoring a composite action, inputs must be mapped into inner steps using GitHub Actions expressions.

For example, map into the script directly:

inputs:
  foo:
    description: 'Test input'
    required: yes
runs:
  using: composite
  steps:
    - run: |
        echo "FOO: ${{inputs.foo}}"
      shell: bash

Or for example, map into the script indirectly via env var:

inputs:
  foo:
    description: 'Test input'
    required: yes
runs:
  using: composite
  steps:
    - run: |
        echo "FOO: $MY_VAR"
      shell: bash
      env:
        MY_VAR: ${{ inputs.foo }}
21reactions
airtower-lunacommented, Aug 19, 2020

Fair enough, but wouldn’t it be simpler to have the same behavior across all kinds of actions? Or is there a technical reason not to provide the INPUT_ environment variables?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to use default github actions env vars for composite ...
I'm trying to utilize some of the default github actions env vars within my composite github action step. I recall reading (the link...
Read more >
Recommended ways to catch missing environment ...
Recommended ways to catch missing environment variables in github actions? · Never deploy to a running production environment. · always run tests ...
Read more >
GitHub Composite Actions - STOP wasting your time and ...
A composite run steps action allows you to combine multiple ... and are the way we can mut input and outputs from and...
Read more >
Using Composite GitHub Actions to make your Workflows ...
This post aims to demonstrate how composite GitHub Actions can be used to to split workflows into smaller, reusable components.
Read more >
Hello from the GitHub Actions: Core .NET SDK - David Pine
The actions/toolkit specifies the standard I/O, and it defines specific environment variables that are used within a GitHub Action workflow.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found