0

I have a job that calls a composite action as below:

  CHANGE_ORDER:

    needs:
      - SETVARS
    runs-on: 'windows-latest'
    steps:

      - name: Process CO Change Order
        uses: mmctech/betech/processCO@mm365

        env:
          SNOWTOKEN: ${{ secrets.SNOW_TOKEN }}

        with:
          environment: 'dev'
          action: “close”
          SNpass: ${{ env.SNOWTOKEN }}

Cat betech/processCO/action.yml

---
name: executeCO

inputs:

  environment:
    required: true
    default: "create"
    type: string

  action:
    required: true
    default: "create"
    type: string

  SNpass:
    required: true

runs:
  using: "composite"
  steps:
    - name: Create CO

      run: |
        if: ${{ inputs.action == ‘create’ }}

        set-location "${{ github.workspace }}\betech\Scripts"         
        $SNpass="${{ inputs.SNpass }}"
        Write-host ./CreateCO.ps1 -myenv "${{ inputs. environment }}" -SNpass $SNpass
      shell: powershell

    - name: Close CO
      run: |

        if: ${{ inputs.action == ‘close’ }}

        set-location "${{ github.workspace }}\betech\Scripts"         
        $SNpass="${{ inputs.SNpass }}"
        Write-host ./CloseCO.ps1 -myenv "${{ inputs. environment }}" -SNpass $SNpass
      shell: powershell

My requirement is that if the action passed is ‘close’ in which case the composite action’s environment variable should not be required i.e required: false else it should be true.

How can I have a condition based input variable definition in a composite workflow.

3
  • IIRC, it's similar to your earlier thread where we established that it's not possible and you have to resort to handle such cases under run sections. You may include these dependencies on inputs in its README for end users. Commented May 30, 2023 at 5:59
  • Sorry i may sound repetitive but please confirm once -> So dynamic definition of composite action inputs variables is not possible? Commented May 30, 2023 at 6:17
  • Yes, it's not supported at the moment. Also, your if conditions in that action seems to be placed incorrectly. Should be above run and not in it. You might want to update those accordingly. Also, those single quotes look different. Commented May 30, 2023 at 6:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.