Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geoffreywiseman/gh-actuse
GitHub CLI Extension to display Github Actions Usage
https://github.com/geoffreywiseman/gh-actuse
gh-actions gh-extension
Last synced: 3 days ago
JSON representation
GitHub CLI Extension to display Github Actions Usage
- Host: GitHub
- URL: https://github.com/geoffreywiseman/gh-actuse
- Owner: geoffreywiseman
- Created: 2021-11-12T18:40:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-29T20:57:47.000Z (over 1 year ago)
- Last Synced: 2024-07-30T18:43:50.894Z (7 months ago)
- Topics: gh-actions, gh-extension
- Language: Shell
- Homepage:
- Size: 17.6 KB
- Stars: 23
- Watchers: 3
- Forks: 3
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GitHub Actions Usage
A simple extension to display the billable usage (in time) of GitHub Actions workflows within the current billable period. This can be used to look at how various repositories are contributing to your overall GitHub Actions usage without needing to download the usage report and calculate subtotals.
The limitations on billable usage and the current billable period is effectively all that's available through the API currently:
- I can't go beyond the current billing period
- I can't see usage minutes that aren't billable, like self-hosted runners, which don't incur billable time on GitHub ActionsThe current implementation is a bash script wrapped around the `gh` cli.
I've rebuilt this extension in Go (golang) using the GitHub Extension binary support in [gh-actions-usage](https://github.com/codiform/gh-actions-usage).
## Installing
You can install the extension using `gh`:
```
❯ gh extension install geoffreywiseman/gh-actuse
Cloning into '~/.local/share/gh/extensions/gh-actuse'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 4 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.
```## Usage
The current usage is extremely simple -- invoke `gh actuse` from any locally checked out repository:```
❯ gh actuse
GitHub Actions UsageWorkflow 'CI' Usage: 15h (911m)
Workflow 'CodeQL' Usage: 3h (183m)
Repo 'project' Total Usage: 18h (1094m)
```Or if you prefer, `gh actuse ` to specify one or more GitHub repositories to which you have access:
```
❯ gh actuse google/go-github google/guava
GitHub Actions UsageRepo google/go-github:
- Workflow 'linter' Usage: 0ms
- Workflow 'tests' Usage: 0ms
- Total Usage: 0msRepo google/guava:
- Workflow 'CI' Usage: 0ms
- Workflow '.github/workflows/dependabot.yml' Usage: 0ms
- Workflow 'Validate Gradle Wrapper' Usage: 0ms
- Total Usage: 0ms
```Or, if you want to get information across a whole organization:
```
❯ gh actuse google
```You need admin scope access to the organization to access the list of repos enabled for GH Actions, though.
## Future Enhancements
Things I've already considered adding and that seem possible to accomplish are listed in GitHub Issues. You're welcome to vote or contribute, or suggest a feature that you'd like that I haven't already listed.
Some things that I'd like to add, but don't see a way to accomplish using the API:
- Actions Storage
- I haven't found the storage usage of actions in the API anywhere, so I'm not displaying it.
- Other Timeframes
- You can only get actions usage for the current time window, near as I can see, so you can't say "for the past three days" or "over the past six months" or "total by week for the past six weeks"On the technology side of things, I was originally planning on building this in Go (golang) as I've seen other GH extensions in Go but near as I can tell that would make it harder to work with private repos -- I'd need some way to get the authorization information, whereas wrapping Bash around `gh api`, ugly tho it is, lets me piggy back on the authorization you've already given `gh`. I may look into this a bit more, because enhancing this extension by building more bash around more GH invocations with limited ability to handle JSON output isn't very appealing.