How to add two numbers #25386
-
Hello, how do I add a number to the GITHUB_RUN_NUMBER, this does not work:
Is it even possible to do a little computation like this? I’ve spent far too long trying to figure this out :slight_smile: |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
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:
|
Beta Was this translation helpful? Give feedback.
-
Thank you, that works well! |
Beta Was this translation helpful? Give feedback.
-
Hi, I tried a similar approach but it doesn’t seem to be working. Any ideas?
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? thanks |
Beta Was this translation helpful? Give feedback.
-
An environment variable set using |
Beta Was this translation helpful? Give feedback.
-
This is an expected behavior.
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. |
Beta Was this translation helpful? Give feedback.
@danielwilson1702
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: