how to get build number in github actions
Oct 10, 2024 am 11:15 AMThis article provides an overview of methods for obtaining the build number in GitHub Actions workflows. The ${{github.run_number}} context variable is commonly used, while additional options include the env function and Actions Toolkit. Practical us
How to get build number in GitHub Actions
How do I retrieve the build number in GitHub Actions workflows?
To retrieve the build number in GitHub Actions workflows, you can use the ${{github.run_number}}
context variable. This variable is automatically set for every workflow run and represents the unique identifier for that particular run. It is a sequential number that starts from 1 for the first run and increments with each subsequent run.
What methods are available to obtain the build number in GitHub Actions?
There are several methods available to obtain the build number in GitHub Actions:
-
Using the
${{github.run_number}}
context variable: This is the most straightforward method and can be used anywhere within a workflow file. -
Using the
env
function: You can use theenv
function to access the build number as an environment variable. For example,${{env.GITHUB_RUN_NUMBER}}
. -
Using the
getBuildNumber()
function from the Actions Toolkit: If you are using the Actions Toolkit, you can use thegetBuildNumber()
function to retrieve the build number.
How can I access the build number in GitHub Actions for specific use cases?
There are various ways to access the build number in GitHub Actions depending on your specific use case:
-
Displaying the build number in the workflow log: You can use the
echo
function to display the build number in the workflow log. For example,echo "Build number: ${{github.run_number}}"
. -
Setting the build number as an output: You can set the build number as an output of a job and then use it in subsequent jobs. For example,
steps: - run: echo "Build number: ${{github.run_number}}" outputs: build_number: ${{steps.run.outputs.message}}
. -
Accessing the build number in a script: You can access the build number in a script by using the
${{github.run_number}}
variable within the script code. -
Using the build number as a parameter in other actions: You can pass the build number as a parameter to other actions by using the
with
keyword. For example,uses: actions/upload-artifact@v2 with: name: my-artifact path: my-path run-number: ${{github.run_number}}
.
The above is the detailed content of how to get build number in github actions. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use git management tools for complete usage of git management tools

The difference between commit and push of git

How to solve the failure of git commit submission

The difference between add and commit of git

What is git code management tool? What is git code management tool?

How to use git management tools Tutorial for using git management tools for beginners
