Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to inject shell to composite action #835

Closed
igagis opened this issue Nov 29, 2020 · 11 comments · Fixed by #1767
Closed

unable to inject shell to composite action #835

igagis opened this issue Nov 29, 2020 · 11 comments · Fixed by #1767
Assignees
Labels
bug Something isn't working Runner Bug Bug fix scope to the runner

Comments

@igagis
Copy link

igagis commented Nov 29, 2020

Describe the bug
Unable to pass the shell via input parameter to the composite action.

To Reproduce
Steps to reproduce the behavior:

  1. create following composite action:
name: 'test actions'
description: 'test action description'
inputs:
  shell:
    description: 'shell to use'
    required: false
    default: bash
runs:
  using: "composite"
  steps:
    - name:
      run: echo "bla bla bla"
      shell: ${{ inputs.shell}}
  1. use the action in some workflow
  2. Job fails on the 'Set up job' phase, printing the following errors:
Current runner version: '2.274.2'
Operating System
Virtual Environment
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'msys2/setup-msys2@v2'
Download action repository 'actions/checkout@main'
Download action repository 'myci-actions/add-pacman-repo@master'
Error: myci-actions\add-pacman-repo\master\action.yml (Line: 25, Col: 14):
Error: myci-actions\add-pacman-repo\master\action.yml (Line: 25, Col: 14): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.shell
Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. myci-actions\add-pacman-repo\master\action.yml (Line: 25, Col: 14): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.shell
   at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check()
   at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String f[...]
Error: Fail to load myci-actions\add-pacman-repo\master\action.yml

where (Line: 25, Col: 14) corresponds to the last line of the action from step 1. I.e. shell: ${{ inputs.shell}}

Expected behavior
The action works fine and uses the shell passed in as input argument to the action.

Runner Version and Platform

windows-latest

@chenghuang-mdsol
Copy link

Yea. this is annoying, please fix this.

@iamFIREcracker
Copy link

Any workaround? Right now, the only one I can think of is, duplicating all my actions steps and have shell set to msys2 {0} on Windows, and bash elsewhere.

@iamFIREcracker
Copy link

iamFIREcracker commented Oct 26, 2021

FYI, rather than duplicating steps, I ended up sym-linking OS-specific shells to a known location, and changed my steps to specify that new location as shell parameter.

    - name: Create bash-or-msys2
      shell: bash
      run: |
        if [[ "$RUNNER_OS" == "Windows" ]]; then
            powershell New-Item -ItemType SymbolicLink \
              -Path  "D:/a/_temp/setup-msys2/bash-or-msys2.cmd" \
              -Target "D:/a/_temp/setup-msys2/msys2.cmd"
        else
            sudo ln -sf $(which bash) /usr/local/bin/bash-or-msys2
        fi
        ...
    - name: Upgrade ASDF to the Latest Version
      shell: bash-or-msys2 {0}
      run: |
        if [[ "${{ inputs.asdf-version }}" != "latest" ]]; then
            echo ::group::Installing ASDF ${{ inputs.asdf-version }}
            ros install asdf/${{ inputs.asdf-version }}
        else
            echo ::group::Installing latest ASDF
            ros install asdf
        fi
        echo ::endgroup::

Not ideal, but not as ugly as duplicating each and every step.

@marten-seemann
Copy link

Now that GitHub Actions supports ifs in steps, this can be simplified a bit:

    - name: create bash-or-msys2 (for bash)
      shell: bash
      if: inputs.shell == 'bash'
      run: sudo ln -sf $(which bash) /usr/local/bin/bash-or-msys2
    - name: create bash-or-msys2 (for msys2)
      shell: bash
      if: inputs.shell == 'msys2 {0}'
      run: |
        if [[ ! -f "D:/a/_temp/setup-msys2/bash-or-msys2.cmd" ]]; then
          powershell New-Item -ItemType SymbolicLink -Path "D:/a/_temp/setup-msys2/bash-or-msys2.cmd" -Target "D:/a/_temp/setup-msys2/msys2.cmd"
        fi

@xucian
Copy link

xucian commented Nov 17, 2021

1 year?

@igagis
Copy link
Author

igagis commented Nov 17, 2021

@tfgstudios this is how software is developed nowadays...

@reuben
Copy link

reuben commented Feb 6, 2022

@reuben
Copy link

reuben commented Feb 6, 2022

@ethanchewy since you wrote the docs above maybe you can comment on the status here?

@nikola-jokic nikola-jokic self-assigned this Mar 17, 2022
@nikola-jokic nikola-jokic added the Runner Bug Bug fix scope to the runner label Mar 17, 2022
@nikola-jokic
Copy link
Contributor

Hey everyone, we are reproducing this issue and we will notify you as soon as it is fixed 😊

@ironstas1k
Copy link

ironstas1k commented Sep 5, 2022

We are still experiencing this issue using ubuntu-latest runners.

The workflow is not valid. .github/workflows/workflow_test.yml (Line: 20, Col: 16): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.shell .github/workflows/workflow_test.yml (Line: 24, Col: 16): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.shell

Workflow

name: Workflow Tests

on:
  workflow_dispatch:
    inputs:
      shell:
        description: 'shell to use'
        required: false
        default: bash
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Verify parameters
        run: echo "cond step"
        shell: ${{ inputs.shell }}

@AvivPeledTalon
Copy link

We are still experiencing this issue using ubuntu-latest runners.

The workflow is not valid. .github/workflows/workflow_test.yml (Line: 20, Col: 16): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.shell .github/workflows/workflow_test.yml (Line: 24, Col: 16): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.shell

Workflow

name: Workflow Tests

on:
  workflow_dispatch:
    inputs:
      shell:
        description: 'shell to use'
        required: false
        default: bash
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Verify parameters
        run: echo "cond step"
        shell: ${{ inputs.shell }}

Also experiencing this.
Did your fix only affect composite actions? It seems like it doesn't affect run steps (they still don't recognize the inputs context)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Runner Bug Bug fix scope to the runner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants