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.
1name: grape2on:3 push:4 branches: [main]5jobs:6 reindex:7 runs-on: ubuntu-latest8 steps:9 - uses: grape-industries/grape-action@v110 with:11 project: <project id>12 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
1POST /grape/{project}/reindex| 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 indexed the project again. The body is the metadata of the project, with branch and commit. |
| 200 | Grape already indexed the commit. The body has skipped: "already indexed at <commit>". |
| 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:
1curl -X POST https://grape-inc.in/grape/$PROJECT/reindex \2 -H "Authorization: Bearer $GRAPE_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{"branch": "main"}'