Skip to content

Conditional running of action steps could be made more concise using run.steps[*].if  #21

Closed
@chgl

Description

@chgl

I believe the conditional handling inside the action could be implemented more concisely by conditionally running steps based in the input instead of always running and checking inside a shell. E.g. instead of

- name: Check if .NET is installed
      run: |
        if $INPUT_DOTNET_VALIDATION_ENABLED || $INPUT_SUSHI_ENABLED; then
          if ! command -v dotnet &> /dev/null
          then
              echo "dotnet could not be found. Please see actions/setup-dotnet to set it up before running this action."
              exit 1
          fi
        fi
      shell: bash
- name: Check if .NET is installed
  if: ${{ inputs.DOTNET_VALIDATION_ENABLED || inputs.INPUT_SUSHI_ENABLED }}
      run: |
          if ! command -v dotnet &> /dev/null
          then
              echo "dotnet could not be found. Please see actions/setup-dotnet to set it up before running this action."
              exit 1
          fi
      shell: bash

This would show the Check if .NET is installed step as disabled in the GitHub workflow view.

(As another nit-picky aside: kebab-case for input parameters generally seems more common in GitHub actions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions