How to make mathematical comparisons in github action expressions

Viewed 889

For a GitHub action workflow, I want to compare two variables in an if condition to determine if a step should be run. However, the comparison seems to happen as a string comparison, e.g., 8060 gets evaluated greater than 65536. How can I force these to be a mathematical comparison?

jobs:
  generate-report:
    runs-on: ubuntu-latest
    name: Generate update review report
    outputs:
      update-report: ${{ steps.set-update-report.outputs.report }}
      update-report-length: ${{ steps.set-update-report.outputs.length }}
    steps:
      - name: Get depdive update report
        id: set-update-report
        run: |
          output="$(depdive update-review paths ./base/ ./)"
          echo "::set-output name=report::${output}"
          length=$(echo ${output} | wc -c )
          echo "::set-output name=length::${length}"


  make-pr-comment:
    runs-on: ubuntu-latest
    name: Comment on PR
    needs: generate-report
    env:
      MAX_ALLOWED_CHARS: 65536
    steps:
      - name: make valid comment
        if: ${{ needs.generate-report.outputs.update-report && needs.generate-report.outputs.update-report-length < env.MAX_ALLOWED_CHARS }}
        # expects mathematical comparison here
        run: |
          echo "valid"
      - name: make comment when output too big
        if: ${{ needs.generate-report.outputs.update-report && needs.generate-report.outputs.update-report-length >= env.MAX_ALLOWED_CHARS }}
        # expects mathematical comparison here
        run: |
          echo "invalid"
1 Answers
Related