Index again from GitHub Actions
Keep a GitHub project up to date. Index it again after each push.
A project that you connect with the Grape GitHub app needs no action: GitHub tells Grape about each push, and Grape indexes the project again. Use the action for a public repository that you added with its URL.
The action
- In the GitHub repository, open Settings, then Secrets and variables, then Actions.
- Add the secret
GRAPE_API_KEY. Its value is your API key. - Add this file as
.github/workflows/grape.yml. Put your project ID in it. The Connect tab of the project shows this file with the ID.
name: grape
on:
push:
branches: [main]
jobs:
reindex:
runs-on: ubuntu-latest
steps:
- uses: grape-industries/grape-action@v1
with:
project: <project id>
token: ${{ secrets.GRAPE_API_KEY }}After each push to the branch, Grape clones the repository again and indexes it again. If Grape already indexed the commit, it does not clone the repository.
Endpoint
POST /v1/projects/{project}/index-jobs| Field | Type | Description |
|---|---|---|
| branch | string | Optional. The branch of the push. It must be the branch that the project follows. |
Use the API key as the bearer token. With an API key, you can index only GitHub projects again. You can do this a maximum of 30 times each hour for each project. To change the branch, use the Settings tab of the project in the app.
Responses
| Status | Meaning |
|---|---|
| 200 | Grape queued the index job. The body is the job: id, status and error. Read GET /v1/projects/{project}/index-jobs/{id} until status is 2 (completed) or 3 (failed). |
| 400 | The branch is not the branch that the project follows, or the project is not a GitHub project. |
| 401 | The API key is missing or wrong, or you made a new key. |
| 404 | Your account has no project with this ID. |
| 429 | More than 30 calls to index again in this hour. |
Without the action
All CI systems can send the same request:
curl -X POST https://grape-inc.in/v1/projects/$PROJECT/index-jobs \
-H "Authorization: Bearer $GRAPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"branch": "main"}'