Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sum expression in github action run-name

I am trying to set dynamic name to workflow run that has a number. The number should be calculated using an expression.

run-name: Perform Operation with ID [SOME_GITHUB_VAR + 1]

Is there a way to perform the above sum operation?

Thanks,

like image 418
Himanshu Sharma Avatar asked Apr 17 '26 22:04

Himanshu Sharma


1 Answers

The run-name can include some expressions and can reference only the github and inputs contexts:

run-name: Deploy to ${{ inputs.deploy_target }} by @${{ github.actor }}

Unfortunately, GitHub Actions don't support math operations inside expressions. So, it's impossible to perform such a calculation for the value of the run-name option.

It's possible for the name value for a job step. You can add up these two numbers in a script and then set it as an environment variable.

Example:

name: 'Sum expression'

on:
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: run number with offset
        env:
          NUM: ${{ github.run_number }}
        run: |
          echo "GITHUB_RUN_NUMBER_WITH_OFFSET=$(($NUM + 200))" >> $GITHUB_ENV

      - name: 'Perform Operation with ID ${{ env.GITHUB_RUN_NUMBER_WITH_OFFSET }}'
        run: echo "Success!"

Result:

result

For more details, read the Setting an environment variable article.

Reference: How to add two numbers.

like image 94
Andrii Bodnar Avatar answered Apr 22 '26 02:04

Andrii Bodnar