fix: allow mapping into env variable INPUT_N from ${{ inputs.n }} #1080

Merged
mfenniak merged 1 commit from mfenniak/forgejo-runner:input_env-fix into main 2025-10-10 21:55:09 +00:00
Owner

When using a reusable workflow such as:

name: "use-inputs-impl"

on:
  workflow_call:
    inputs:
      image:
        description: "Image to be used in job"
        type: string
        required: false
        default: "docker.io/alpine:3.22"
      condition:
        description: "Only run a job if this is true"
        type: string
        required: false
        default: false

jobs:
  works:
    runs-on: docker
    container:
      image: alpine:3.22
    env:
      INPUT_IMAGE: ${{ inputs.image }}
      INPUT_CONDITION: ${{ inputs.condition }}
    steps:
      - run: echo "Hello world from Alpine"
      - run: cat /etc/alpine-release
      - run: echo "INPUT_IMAGE=$INPUT_IMAGE"
      - run: echo "INPUT_CONDITION=$INPUT_CONDITION"

The runner will currently output un-evaluated expressions:

INPUT_IMAGE=${{ inputs.image }}
INPUT_CONDITION=${{ inputs.condition }}

Internally, the workflow is using INPUT_... environment variables to transfer data into local reusable workflows, and the order of evaluation in getEvaluatorInputs was preferring to use the un-evaluated value, over the evaluated value.

  • bug fixes
    • PR: fix: allow mapping into env variable INPUT_N from ${{ inputs.n }}
When using a reusable workflow such as: ```yaml name: "use-inputs-impl" on: workflow_call: inputs: image: description: "Image to be used in job" type: string required: false default: "docker.io/alpine:3.22" condition: description: "Only run a job if this is true" type: string required: false default: false jobs: works: runs-on: docker container: image: alpine:3.22 env: INPUT_IMAGE: ${{ inputs.image }} INPUT_CONDITION: ${{ inputs.condition }} steps: - run: echo "Hello world from Alpine" - run: cat /etc/alpine-release - run: echo "INPUT_IMAGE=$INPUT_IMAGE" - run: echo "INPUT_CONDITION=$INPUT_CONDITION" ``` The runner will currently output un-evaluated expressions: ``` INPUT_IMAGE=${{ inputs.image }} INPUT_CONDITION=${{ inputs.condition }} ``` Internally, the workflow is using `INPUT_...` environment variables to transfer data into local reusable workflows, and the order of evaluation in `getEvaluatorInputs` was preferring to use the un-evaluated value, over the evaluated value. <!--start release-notes-assistant--> <!--URL:https://code.forgejo.org/forgejo/runner--> - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/1080): <!--number 1080 --><!--line 0 --><!--description Zml4OiBhbGxvdyBtYXBwaW5nIGludG8gZW52IHZhcmlhYmxlIElOUFVUX04gZnJvbSAke3sgaW5wdXRzLm4gfX0=-->fix: allow mapping into env variable INPUT_N from ${{ inputs.n }}<!--description--> <!--end release-notes-assistant-->
Author
Owner

I can't see any reason why environment variables starting with INPUT_* are considered to be inputs, so I'm removing this and running the full test suite to see if anything pops up. If nothing comes up, I'll add test automation covering the expected working case.

I can't see any reason why environment variables starting with `INPUT_*` are considered to be inputs, so I'm removing this and running the full test suite to see if anything pops up. If nothing comes up, I'll add test automation covering the expected working case.
First-time contributor

This workflow looks invalid. Have you tested it how GitHub reacts? Per documentation it says that INPUT_ environment variable is created for each input. Manually creating environment variable that would overwrite what input sets sounds like invalid case. This workflow should work without env being declared.

GitHub seems to allow re-declaration of INPUT_ environment variables but evaluates inputs before assigning them properly, so this PR would make it align with how it behaves.

~~This workflow looks invalid. Have you tested it how GitHub reacts? Per [documentation](https://docs.github.com/en/actions/reference/workflows-and-actions/metadata-syntax#inputs) it says that `INPUT_` environment variable is created for each input. Manually creating environment variable that would overwrite what `input` sets sounds like invalid case. This workflow should work without `env` being declared.~~ GitHub seems to allow re-declaration of `INPUT_` environment variables but evaluates `inputs` before assigning them properly, so this PR would make it align with how it behaves.
mfenniak force-pushed input_env-fix from 617be783d1
Some checks failed
issue-labels / release-notes (pull_request_target) Successful in 7s
checks / validate pre-commit-hooks file (pull_request) Successful in 58s
checks / validate mocks (pull_request) Successful in 1m33s
checks / build and test (pull_request) Successful in 4m27s
checks / runner exec tests (pull_request) Successful in 39s
Integration tests for the release process / release-simulation (pull_request) Successful in 6m39s
checks / runner integration tests (pull_request) Successful in 6m42s
checks / integration tests (pull_request) Failing after 14m44s
to fe409b162c
All checks were successful
checks / validate pre-commit-hooks file (pull_request) Successful in 1m1s
checks / validate mocks (pull_request) Successful in 1m21s
checks / build and test (pull_request) Successful in 1m36s
checks / runner exec tests (pull_request) Successful in 46s
Integration tests for the release process / release-simulation (pull_request) Successful in 6m28s
checks / runner integration tests (pull_request) Successful in 7m12s
checks / integration tests (pull_request) Successful in 17m19s
issue-labels / release-notes (pull_request_target) Successful in 7s
cascade / debug (pull_request_target) Has been skipped
cascade / forgejo (pull_request_target) Successful in 55s
cascade / end-to-end (pull_request_target) Successful in 6s
2025-10-10 19:18:55 +00:00
Compare
mfenniak changed title from WIP: fix: don't map env variables INPUT_... into ${{ inputs.... }} to fix: allow mapping into env variable INPUT_N from ${{ inputs.n }} 2025-10-10 19:21:08 +00:00
Author
Owner

@proton-ab This is a composite workflow, which if following the documentation you've linked, would fall into "... then it will not automatically get INPUT_<VARIABLE_NAME>".

I think the workflow intent is easily understood, regardless? This doesn't seem extra-ordinary to me:

    env:
      INPUT_IMAGE: ${{ inputs.image }}
      INPUT_CONDITION: ${{ inputs.condition }}
@proton-ab This is a composite workflow, which if following the documentation you've linked, would fall into "... then it will not automatically get INPUT_<VARIABLE_NAME>". I think the workflow intent is easily understood, regardless? This doesn't seem extra-ordinary to me: ``` env: INPUT_IMAGE: ${{ inputs.image }} INPUT_CONDITION: ${{ inputs.condition }} ```
First-time contributor

Yeah, sorry for confusion. Here's related GitHub issue https://github.com/actions/runner/issues/665 that documents this method as workaround too, so we very much want to have this sorted.

Yeah, sorry for confusion. Here's related GitHub issue https://github.com/actions/runner/issues/665 that documents this method as workaround too, so we very much want to have this sorted.
earl-warren left a comment

Remarkably simple fix 👍

Remarkably simple fix 👍
Contributor

cascading-pr updated at actions/setup-forgejo#716

cascading-pr updated at https://code.forgejo.org/actions/setup-forgejo/pulls/716
mfenniak deleted branch input_env-fix 2025-10-10 21:55:10 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
forgejo/runner!1080
No description provided.