actions-usage

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 13 Imported by: 0

README

actions-usage

Find your GitHub Actions usage across a given organisation or user account.

build License Total downloads

Example console output

Example console output for the inlets OSS repos

Includes total runtime of all workflow runs and workflow jobs, including where the jobs were run within inclusive, free, billed minutes, or on self-hosted runners.

This data is not available within a single endpoint in GitHub's REST or GraphQL APIs, so many different API calls are necessary to build up the usage statistics.

repos = ListRepos(organisation || user)
   for each Repo
       ListWorkflowRuns(Repo)
          for each WorkflowRun
             jobs = ListWorkflowJobs(WorkflowRun)
sum(jobs)

If your team has hundreds of repositories, or thousands of builds per month, then the tool may exit early due to exceeding the API rate-limit. In this case, we suggest you run with --days=10 and multiply the value by 3 to get a rough picture of 30-day usage.

Usage

This tool is primarily designed for use with an organisation, however you can also use it with a regular user account by changing the --org flag to --user.

Or create a Classic Token with: repo and admin:org and save it to ~/pat.txt. Create a short lived duration for good measure.

We recommend using arkade to install this CLI, however you can also download a binary from the releases page.

# sudo is optional for this step
curl -SLs https://get.arkade.dev | sudo sh

arkade get actions-usage
sudo mv $HOME/.arkade/bin/actions-usage /usr/local/bin/

Collecting usage before you sign up to actuated.dev

We sometimes ask users to run this tool before a call with the actuated team. It helps us gauge your usage, find potential wins and recommend a plan/server.

actions-usage \
 --by-repo \
 --punch-card \
 --org openfaas \
 --token-file ~/pat.txt \
 --days 28

If you have either a large or a busy repo - you may want to run with --days 14 or --days 7 once your rate limit has reset.

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer $(cat ~/pat.txt)"\
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/rate_limit

If you're still unable to get the tool to run within your rate-limit, even with 7 days of data, the billing summary from your organisation for actions minutes and what plan you're on could also work, but is quite coarse in comparison.

Output

Example output:

Usage report generated by self-actuated/actions-usage.

Total repos: 44
Total private repos: 0
Total public repos: 44

Total workflow runs: 128
Total workflow jobs: 173

Total users: 4
Longest build: 13m50s
Average build time: 2m55s
Total usage: 8h24m21s (504 mins)

You can also run the tool against your personal account:

actions-usage --user alexellis --token-file ~/pat.txt

Get a punch-card of which days have the most commits by adding the -punch-card flag:

Day            Builds
Monday         7
Tuesday        22
Wednesday      43
Thursday       49
Friday         19
Saturday       4
Sunday         12
Total          156

You can use the -by-repo flag to get a detailed breakdown of usage by GitHub repository - sorted by number of builds.

Longest build: 4h12m40s
Average build time: 2m37s

Repo                                      Builds         Success        Failure        Cancelled      Skipped        Total          Average        Longest
actuated-samples/k3sup-matrix-test        144            140            1              3              0              1h31m33s       38s            2m0s
actuated-samples/specs                    36             25             0              11             0              6m15s          10s            25s
actuated-samples/minty                    24             6              18             0              0              2m32s          6s             10s
actuated-samples/debug-ssh                17             12             1              4              0              9h12m33s       32m30s         4h12m40s
actuated-samples/matrix-build             14             14             0              0              0              31s            2s             4s
actuated-samples/dns                      9              3              0              6              0              40s            4s             18s
actuated-samples/ebpf                     5              2              3              0              0              39s            8s             9s
actuated-samples/cilium-test              4              1              3              0              0              9m16s          2m19s          6m49s
actuated-samples/openfaas-helm            4              2              2              0              0              3m42s          56s            1m54s
actuated-samples/ivan-ssl                 3              3              0              0              0              13s            4s             5s
actuated-samples/kind-tester              1              0              1              0              0              14m56s         14m56s         14m56s
actuated-samples/kernel-builder-linux-6.0 1              1              0              0              0              1m16s          1m16s          1m16s

Total usage: 11h24m6s (684 mins)

You can filter the output by specifying repositories to include with the -include and/or -include-file option.

actions-usage ... -include actuated-samples/ebpf,actuated-samples/dns

---
Longest build: 18s
Average build time: 6s

Repo                                      Builds         Success        Failure        Cancelled      Skipped        Total          Average        Longest
actuated-samples/dns                      9              3              0              6              0              40s            4s             18s
actuated-samples/ebpf                     5              2              3              0              0              39s            8s             9s

Total usage: 1m19s (1 min)

Development

All changes must be proposed with an Issue prior to working on them or sending a PR. Commits must have a sign-off message, i.e. git commit -s

git clone https://github.com/actuated/actions-usage
cd actions-usage

go run . --org actuated-samples --token-file ~/pat.txt

Author

This tool was created as part of actuated - secure, fast BYO runners for GitHub Actions. actuated is developed by OpenFaaS Ltd.

Within the dashboard, customers get built-in charts for overall usage on a GitHub organisation and a repo-level break down of passing/failing builds and total time spent in each.

Insights for customers

License

MIT

Contributions are welcome, however an Issue must be raised and approved before submitting a PR.

For typos, raise an Issue and a contributor will fix this. It's easier for everyone that way.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL