How to add two numbers

Hello, how do I add a number to the GITHUB_RUN_NUMBER, this does not work:

      GITHUB_RUN_NUMBER_WITH_OFFSET: ${{ github.run_number + 200 }}

Unexpected symbol: '+'. Located at position 19 within expression: github.run_number + 200

Is it even possible to do a little computation like this? I’ve spent far too long trying to figure this out :slight_smile:

1 Like


Github actions doesn’t support math operations in expressions inside ${{  }}. You could add up these two numbers in bash script and then use set-env command to give its value to an environment variable, please try my example: 

on: push

    runs-on: ubuntu-latest
    - name: run number with offset
          NUM: ${{ github.run_number }}
      run: |
          echo ::set-env name=GITHUB_RUN_NUMBER_WITH_OFFSET::$(($NUM+200))
1 Like

Thank you, that works well!

Hi, I tried a similar approach but it doesn’t seem to be working. Any ideas?

  - name: My Code
          OLDNUM: ${{ }}
      run: |
        echo "Current Number is $OLDNUM"
        echo ::set-env name=NEWNUM::$(($OLDNUM+1))
        echo "New Number is $NEWNUM"

It gets the output “mynum” correctly, I see it in the echo. But it doesn’t perform the operation of adding 1 to it or setting the new env var. I get an empty variable. Any ideas?


An environment variable set using ::set-env is not available within the same step, only the following ones (see documentation). If you want to use it in the same step you should be able to use normal Bash variable assignment.

This is an expected behavior.

::set-env name={name}::{value}

This command creates or updates an environment variable for any actions running next in a job. The action that creates or updates the environment variable does not have access to the new value, but all subsequent actions in a job will have access.