Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: self-actuated/actions-usage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.5
Choose a base ref
...
head repository: self-actuated/actions-usage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Mar 18, 2023

  1. Update README.md

    alexellis authored Mar 18, 2023
    Copy the full SHA
    748c7db View commit details
  2. Update README.md

    alexellis authored Mar 18, 2023
    Copy the full SHA
    ed42474 View commit details
  3. Update README.md

    alexellis authored Mar 18, 2023
    Copy the full SHA
    5e0b14e View commit details

Commits on Apr 4, 2023

  1. Update .DEREK.yml

    alexellis authored Apr 4, 2023
    Copy the full SHA
    04b43f2 View commit details

Commits on Apr 6, 2023

  1. Add success vs. failure etc for jobs into summary

    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed Apr 6, 2023
    Copy the full SHA
    4dda81b View commit details
  2. Update README.md

    alexellis authored Apr 6, 2023
    Copy the full SHA
    f8b057a View commit details

Commits on Apr 18, 2023

  1. Add builds per day

    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed Apr 18, 2023
    Copy the full SHA
    d7e5fdc View commit details

Commits on Apr 19, 2023

  1. Rename -since to -days and add -token-file flag

    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed Apr 19, 2023
    Copy the full SHA
    4097247 View commit details
  2. Update README

    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed Apr 19, 2023
    Copy the full SHA
    1697888 View commit details
  3. Update README.md

    alexellis authored Apr 19, 2023
    Copy the full SHA
    731b5b6 View commit details
  4. Update README.md

    alexellis authored Apr 19, 2023
    Copy the full SHA
    80587e2 View commit details

Commits on May 5, 2023

  1. Add repo-level breakdowns

    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed May 5, 2023
    Copy the full SHA
    f7fe048 View commit details
  2. Update README about -by-repo flag

    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed May 5, 2023
    Copy the full SHA
    873a22b View commit details

Commits on May 18, 2023

  1. Fix issue with counting up jobs that didn't finish

    We saw an issue with a negative amount for a new customer
    that only showed in the repo-level breakout.
    
    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed May 18, 2023
    Copy the full SHA
    3541869 View commit details

Commits on May 29, 2023

  1. Update README.md

    alexellis authored May 29, 2023
    Copy the full SHA
    1a075ec View commit details
  2. Update README.md

    alexellis authored May 29, 2023
    Copy the full SHA
    21fc4d9 View commit details

Commits on May 30, 2023

  1. Update README.md

    alexellis authored May 30, 2023
    Copy the full SHA
    95c0d4d View commit details

Commits on May 31, 2023

  1. Update README.md

    alexellis authored May 31, 2023
    Copy the full SHA
    fbd6442 View commit details

Commits on Jun 16, 2023

  1. Update README.md

    alexellis authored Jun 16, 2023
    Copy the full SHA
    4b31611 View commit details

Commits on Jun 27, 2023

  1. Add repo filtering functionality

    Signed-off-by: Nana Kwadwo <agyemang.nana.b@gmail.com>
    bxffour authored and alexellis committed Jun 27, 2023
    Copy the full SHA
    0245cdc View commit details

Commits on Sep 14, 2023

  1. Fixes #14 by adding enterprise url support

    Also only check rate limit when there's one set (our ghe apparently
        doesn't)
    
    Signed-off-by: Gavin Mogan <gmogan@digitalocean.com>
    halkeye authored and alexellis committed Sep 14, 2023
    Copy the full SHA
    e6781a6 View commit details

Commits on Nov 13, 2023

  1. Defensive coding on summary

    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed Nov 13, 2023
    Copy the full SHA
    d8b1fe2 View commit details

Commits on May 1, 2024

  1. Update to latest GitHub client

    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed May 1, 2024
    Copy the full SHA
    85317a9 View commit details
  2. Tidy go.mod

    Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
    alexellis committed May 1, 2024
    Copy the full SHA
    8658462 View commit details
Showing with 436 additions and 69 deletions.
  1. +0 −1 .DEREK.yml
  2. +124 −15 README.md
  3. +4 −10 go.mod
  4. +6 −22 go.sum
  5. +302 −21 main.go
1 change: 0 additions & 1 deletion .DEREK.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
curators:
- alexellis
- welteki
- Jasstkn

features:
- dco_check
139 changes: 124 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
## actions-usage

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

[![build](https://github.com/self-actuated/actions-usage/actions/workflows/build.yml/badge.svg)](https://github.com/self-actuated/actions-usage/actions/workflows/build.yml)
![License](https://img.shields.io/github/license/self-actuated/actions-usage)
![Total downloads](https://img.shields.io/github/downloads/self-actuated/actions-usage/total)

![Example console output](https://pbs.twimg.com/media/FrbYxbwWwAMvQZN?format=jpg&name=large)
> Example console output for the [inlets OSS repos](https://github.com/inlets)
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)
repos = ListRepos(organisation || user)
for each Repo
ListWorkflowRuns(Repo)
for each WorkflowRun
@@ -23,28 +30,118 @@ This tool is primarily designed for use with an organisation, however you can al

Or create a [Classic Token](https://github.com/settings/tokens) with: repo and admin:org and save it to ~/pat.txt. Create a short lived duration for good measure.

Download a binary from the [releases page](https://github.com/self-actuated/actions-usage/releases)
We recommend using arkade to install this CLI, however you can also download a binary from the [releases page](https://github.com/self-actuated/actions-usage/releases).

## Output
```sh
# 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](https://actuated.dev). It helps us gauge your usage, find potential wins and recommend a plan/server.

```bash
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.

```bash
actions-usage --org openfaas --token $(cat ~/pat.txt)
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

Fetching last 30 days of data (created>=2023-01-29)
Example output:

Total repos: 45
```
Usage report generated by self-actuated/actions-usage.
Total repos: 44
Total private repos: 0
Total public repos: 45
Total public repos: 44
Total workflow runs: 128
Total workflow jobs: 173
Total workflow runs: 95
Total workflow jobs: 113
Total usage: 6h16m16s (376 mins)
Total users: 4
Longest build: 13m50s
Average build time: 2m55s
Total usage: 8h24m21s (504 mins)
```

As a user:
You can also run the tool against your personal account:

```bash
actions-usage --user alexellis --token $(cat ~/pat.txt)
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.

```bash
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
@@ -55,10 +152,22 @@ All changes must be proposed with an Issue prior to working on them or sending a
git clone https://github.com/actuated/actions-usage
cd actions-usage

go run . --org actuated-samples --token $(cat ~/pat.txt)
go run . --org actuated-samples --token-file ~/pat.txt
```

## Author

This tool was created as part of [actuated.dev](https://actuated.dev) by OpenFaaS Ltd.
This tool was created as part of [actuated](https://actuated.dev) - secure, fast BYO runners for GitHub Actions. actuated is developed by [OpenFaaS Ltd](https://openfaas.com).

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](https://pbs.twimg.com/media/FqnJ8rLXgAEnJDZ?format=png&name=medium)](https://twitter.com/alexellisuk/status/1633059062639108096/)

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

14 changes: 4 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
module github.com/self-actuated/actions-usage

go 1.19
go 1.21

require (
github.com/docker/go-units v0.5.0
github.com/google/go-github/v50 v50.1.0
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
github.com/google/go-github/v61 v61.0.0
golang.org/x/oauth2 v0.19.0
)

require (
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
google.golang.org/appengine v1.6.7 // indirect
)
require github.com/google/go-querystring v1.1.0 // indirect
28 changes: 6 additions & 22 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github/v50 v50.1.0 h1:hMUpkZjklC5GJ+c3GquSqOP/T4BNsB7XohaPhtMOzRk=
github.com/google/go-github/v50 v50.1.0/go.mod h1:Ev4Tre8QoKiolvbpOSG3FIi4Mlon3S2Nt9W5JYqKiwA=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=
github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
Loading