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,
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:

For more details, read the Setting an environment variable article.
Reference: How to add two numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With