Load the information for the runners that are available for the organization or the repository, including status checks. Can be used to verify the amount of runners for a label is as expected.
Security
All releases include a Software Bill of Materials (SBOM) in SPDX format (sbom.spdx.json) that provides detailed information about the dependencies used in this action. The SBOM is generated from GitHub's dependency graph and included as a release asset.
Example
Basic usage:
- uses: devops-actions/load-runner-info@7f8c07227aa6176e94e4eeb912016bb0a9d33796 #v1.0.10 id: load-runner-info-org with: accessToken: ${{ secrets.access_token }} organization: ${{ env.organization }}
Read the complete example for using the outputs as well.
Inputs
| Name | Type | Description |
|---|---|---|
organization |
string | The slug of the organization to load the runners from |
repo |
string | The slug of the repo to load the runners from, organization required as well |
accessToken |
string | The access token to use to connect to the GitHub API |
Access token information
To run this action at the organization level, the access token must have scope admin:org (PAT) or org:Self-hosted runners (GitHub App).
To run this action at the repository level, the access token must have scope owner:repo
Outputs
| Name | Type | Description |
|---|---|---|
runners |
string | A JSON string with the runner information available |
grouped |
string | A JSON string with the number of runner grouped by their labels, also indicating their status |
When there are so many runners the JSON gets to large to use, use the filebased outputs instead:
| Name | Type | Description |
|---|---|---|
runners-file-location |
string | The path to the file with the runner information available |
grouped-file-location |
string | The path to the file with the number of runners grouped by their labels, also indicating their status |
Runners output example:
{
"total_count": 1,
"runners": [
{
"id": 2,
"name": "my-runner",
"os": "windows",
"status": "online",
"busy": false,
"labels": [
{
"id": 1,
"name": "self-hosted",
"type": "read-only"
},
{
"id": 2,
"name": "Windows",
"type": "read-only"
},
{
"id": 3,
"name": "X64",
"type": "read-only"
}
]
}
]
}Grouped output example:
[
{ "name": "self-hosted", "counter": 1, "status": 1 },
{ "name": "Windows", "counter": 1, "status": 1 },
{ "name": "X64", "counter": 1, "status": 1 }
]Note: status indicates the number of the runners that is online for that label.
Full usage example
Below is an example how I use this action to load the information on the available runners as well as test if there are enough runners online (see step Test runner info).
jobs: test-from-organization: runs-on: ubuntu-latest steps: - name: Get access token id: get_workflow_token uses: peter-murray/workflow-application-token-action@dc0413987a085fa17d19df9e47d4677cf81ffef3 #3.3.0 with: application_id: ${{ secrets.APPLICATION_ID }} application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }} - uses: devops-actions/load-runner-info@7f8c07227aa6176e94e4eeb912016bb0a9d33796 #v1.0.10 id: load-runner-info-org with: accessToken: ${{ steps.get_workflow_token.outputs.token }} organization: ${{ env.organization }} - name: Upload result file as artefact for inspection uses: actions/upload-artifact@v4 with: name: runners-organization-${{ env.organization }} path: - ${{ steps.load-runner-info-org.outputs.runners-file-location }} - ${{ steps.load-runner-info-org.outputs.grouped-file-location }} - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 name: Test runner info with: script: | const info = JSON.parse(`${{ steps.load-runner-info-org.outputs.runners-file-location }}`) if (info.length == 0) { core.error('No runners found') return } console.log(`Found [${info.runners.length}] runner(s)`) for (let num = 0; num < info.runners.length; num++) { const runner = info.runners[num] console.log(`- name: [${runner.name}]`) } console.log(``) const grouped = JSON.parse(`${{ steps.load-runner-info-org.outputs.grouped-file-location }}`) console.log(`Found ${grouped.length} runner label(s)`) for (let num = 0; num < grouped.length; num++) { const group = grouped[num] console.log(`- label: [${group.name}], runner with this label: [${group.counter}] with [${group.status}] online runners`) } // example of a test you can do on the amount of runners online with this label const selfHosted = grouped.find(group => group.name === 'self-hosted') if (selfHosted.status > 10) { core.error(`Too many runners with label "self-hosted" found`) return } // example of a test you can do on the amount of runners online with this label if (selfHosted.status < selfHosted.counter) { core.error(`There are [${selfHosted.counter - selfHosted.status}] runners offline`) return }