1- # GitHub API Usage Tracker
1+ <div align =" center " >
2+
3+ <img src =" assets/header.svg " alt =" GitHub API Usage Tracker " width =" 600 " />
4+
5+ <br ><br >
6+
7+ [ ![ GitHub Actions] ( https://img.shields.io/badge/GitHub-Action-2088FF?style=for-the-badge&logo=github-actions&logoColor=white )] ( https://github.com/features/actions )
8+ [ ![ Node.js] ( https://img.shields.io/badge/Node.js-20+-339933?style=for-the-badge&logo=node.js&logoColor=white )] ( https://nodejs.org/ )
9+ [ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge )] ( LICENSE )
10+
11+ ---
12+
13+ </div >
214
315Track how many GitHub API requests a workflow job consumes, parttioned by bucket (core, GraphQL, search, etc.).
416
@@ -8,14 +20,26 @@ This action captures the rate-limit state at job start and compares it with the
820
921``` yaml
1022jobs :
11- example :
23+ track :
1224 runs-on : ubuntu-latest
25+ outputs :
26+ usage : ${{ steps.usage.outputs.usage }}
1327 steps :
1428 - uses : actions/checkout@v4
1529 - uses : hesreallyhim/github-api-usage-tracker@v1
16- - run : echo "Core API used: ${{ steps.usage.outputs.usage }}"
30+ id : usage
31+
32+ report :
33+ runs-on : ubuntu-latest
34+ needs : track
35+ steps :
36+ - run : echo "Core API used: ${{ needs.track.outputs.usage }}"
1737` ` `
1838
39+ <div align="center">
40+ <img src="assets/flow-diagram.svg" alt="API Usage Tracking Flow" width="100%"/>
41+ </div>
42+
1943## Inputs
2044
2145| Name | Description | Default |
@@ -26,26 +50,37 @@ jobs:
2650
2751## Outputs
2852
29- | Name | Description |
30- | ----- | -------------------------------------------------------- |
31- | usage | JSON string mapping API area (" bucket") -> requests used |
53+ | Name | Description |
54+ | ----- | --------------------------------------------------------------------------------- |
55+ | usage | JSON string with total, duration_ms, and buckets_data (per- bucket used/remaining) |
3256
3357Example output:
3458
3559` ` ` json
3660{
37- " core " : 45,
38- " graphql " : 10,
39- " search " : 5
61+ " total " : 60,
62+ " duration_ms " : 12345,
63+ " buckets_data " : {
64+ " core " : { "used": 45, "remaining": 4955 },
65+ " graphql " : { "used": 10, "remaining": 4990 },
66+ " search " : { "used": 5, "remaining": 25 }
67+ }
4068}
4169```
4270
4371## Notes
4472
4573- Usage counts may be affected by other workflows in the repo, and therefore should not be considered 100% precise as measurements of the current job.
4674- The action uses pre and post job hooks to snapshot the rate limit, so you only need to use it in one step - the rest will be handled automatically.
75+ - Output is set in the post step, so it is only available after the job completes (use job outputs if needed).
4776- Logs are emitted via ` core.debug() ` . Enable step debug logging to view them.
4877
78+ ---
79+
4980## License
5081
82+ <div align =" center " >
83+
5184MIT © 2025 Really Him
85+
86+ </div >
0 commit comments