This action gets you detailed statistics of your workflow runs.
GitHub API token.
Workflow ID. You can use the workflow file's name.
Pull request number. Can be optionally used when the action cannot find the PR number correctly.
Detailed workflow run statistics.
All examples assume you already have a
build.yml
in.github/workflows/
that is the workflow you'd like to get stats for.
-
Using the
workflow_dispatch
event (Recommended). This is recommended for projects that accept external contributions from forks.-
Include a final step under
jobs.<job-id>.steps
in.github/workflows/build.yml
.steps: - name: Trigger build stats action uses: peter-evans/repository-dispatch@v1 with: token: ${{ secrets.TOKEN }} # Use a custom personal access token. event-type: trigger-stats client-payload: '{"pull_request": {"number": "${{ github.event.number }}"}}'
This will manually trigger the stats workflow.
ℹ️ Note for open-source projects that accept PRs from external forks – for this
workflow_dispatch
to work, you will need to turn on "Run workflows from fork pull requests" and "Send secrets to workflows from fork pull requests" in your repository's settings. -
Create a separate workflow, say
.github/workflows/build-stats.yml
that will listen to thetrigger-stats
event from the above step.name: Workflow run stats on: repository_dispatch: types: [trigger-stats] jobs: post-stats: runs-on: ubuntu-latest steps: - name: Post stats uses: 'getoslash/github-build-stats-action@latest' with: token: ${{ secrets.GITHUB_TOKEN }} workflowId: build.yml
-
-
Using the
workflow_run
event. This is recommended for projects that accept only same-origin PRs and not PRs from external forks.-
Create a separate workflow, say
.github/workflows/build-stats.yml
.name: Workflow run stats on: workflow_run: workflows: - 'build.yml' types: - completed jobs: post-stats: runs-on: ubuntu-latest steps: - name: Post stats uses: 'getoslash/github-build-stats-action@latest' with: token: ${{ secrets.GITHUB_TOKEN }} workflowId: build.yml pullRequest: ${{ github.event.number }}
-
The code in this project is released under the MIT License.