Skip to content

Github Action that gets you detailed statistics of your workflow runs.

License

Notifications You must be signed in to change notification settings

getoslash/github-build-stats-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Build Stats

GitHub release Release codecov Open in Visual Studio Code

This action gets you detailed statistics of your workflow runs.

Screenshot

Inputs

token

GitHub API token.

workflowId

Workflow ID. You can use the workflow file's name.

pullRequest (optional)

Pull request number. Can be optionally used when the action cannot find the PR number correctly.

Outputs

stats

Detailed workflow run statistics.

Example usage

All examples assume you already have a build.yml in .github/workflows/ that is the workflow you'd like to get stats for.

  1. Using the workflow_dispatch event (Recommended). This is recommended for projects that accept external contributions from forks.

    1. 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.

    2. Create a separate workflow, say .github/workflows/build-stats.yml that will listen to the trigger-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
  2. Using the workflow_run event. This is recommended for projects that accept only same-origin PRs and not PRs from external forks.

    1. 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 }}

Licenses

The code in this project is released under the MIT License.

FOSSA Status