Home > Blockchain >  Git actions - simple if statement condition
Git actions - simple if statement condition

Time:09-07

Hi Please note that the if condition gets executed in the below case even though the variable "highPriority" is zero.

- name: Polaris Result
        id: polaris_result
        run: |
          highPriority=$(cat sample.json | jq '.issueSummary.high')
          echo "$highPriority"
          echo "::set-output name=highPriority::$highPriority"
 
      - name: fail If crosses threshold for high priority issues
        if: ${{ steps.polaris_result.outputs.highPriority }} > 0
        run: exit 1

note that echo "$highPriority" outputs "0". However the if condition gets executed in this case which should not be

CodePudding user response:

You should surround all the expression with the { } bracet. please try:

    if: ${{ steps.polaris_result.outputs.highPriority  > 0 }}

instead of:

    if: ${{ steps.polaris_result.outputs.highPriority }} > 0

See expression section in the doc for some context

  • Related