diff --git a/README.md b/README.md index d4879a7..0120935 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,35 @@ -# Sweep or sleep (Github API quota action step) +# GH API Confine [![GitHub Super-Linter](https://github.com/actions/typescript-action/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter) ![CI](https://github.com/actions/typescript-action/actions/workflows/ci.yml/badge.svg) -**Sweep or sleep** is a humble Github action step, which allows to easily check your remaining Github API quota and act accordingly. If your balance drops below your specified lower bound, you can kill (sweep) your workflow run or wait (sleep) until your allotment renews. The step will also set a `${GITHUB_REMAINING_API_QUOTA}` environment variable for your convenience. +**GH API Confine** (GitHub API Quota Limiter) is a humble Github action step designed to help you use the GitHub API more effectively. + +With **GH API Confine**, you can easily monitor your remaining GitHub API quota and act accordingly. Specify a threshold and either delay or terminate your workflow, if your quota falls below this limit. +## Features + +- **Quota monitoring:** The step keeps track of your GitHub API quota, helping you stay within your allocated limits. + +- **Customizable action:** Define how **GH API Confine** should respond when your API quota falls below a specified threshold. Choose between three modes: + - **Peep (Observe):** Take no further action beyond checking the quota. + - **Sleep (Wait):** Delay the completion of the step until shortly after your API quota renews, maximizing the chances of successful job completion. + - **Sweep (Terminate):** Immediately terminate the workflow run to prevent further API usage if your quota is too low. + +### Inputs + +| Input | Description | Required| Default | +|---------------|----------------------------------------------|---------|---------| +| `actionToTake` | Select between 'peep', 'sleep' and 'sweep'. | No | sweep | +| `threshold` | Context string to filter the statuses API | No | 50 | +| `resource`| Monitored Github API resource: One of 'core', 'search', 'graphql', 'integration_manifest' or 'code_scanning_upload' | No | core | +| `token` | Github API token to use for the action. Defaults to your current one. | No | ${{github.token}} | + + +### Outputs + +| Output | Description | +|--------|-------------| +| result | Failure or success result of the status | ## Usage diff --git a/action.yml b/action.yml index 053f583..5936af7 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: 'Sweep or sleep action' +name: 'GitHub API confine' description: 'This action can be used to obtain the remaining Github API quota and act accordingly.' @@ -12,7 +12,7 @@ inputs: for quota renewal).' required: false default: 'sweep' - lowerBound: + threshold: description: 'Minimum remaining API requests required to proceed.' required: false default: '50' diff --git a/package.json b/package.json index 5066096..908675f 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,24 @@ { - "name": "typescript-action", - "description": "GitHub Actions TypeScript template", + "name": "gh-api-confine", + "description": "GitHub API confine", "version": "0.0.0", - "author": "", + "author": "Matthias Zepper", "private": true, - "homepage": "https://github.com/actions/typescript-action", + "homepage": "https://github.com/MatthiasZepper/gh-api-confine", "repository": { "type": "git", - "url": "git+https://github.com/actions/typescript-action.git" + "url": "git+https://github.com/MatthiasZepper/gh-api-confine.git" }, "bugs": { - "url": "https://github.com/actions/typescript-action/issues" + "url": "https://github.com/MatthiasZepper/gh-api-confine/issues" }, "keywords": [ "actions", - "node", - "setup" + "GitHub", + "API", + "rate-limiter", + "quota", + "balance" ], "exports": { ".": "./dist/index.js"