> ## Documentation Index
> Fetch the complete documentation index at: https://context7.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Actions

> Automatically refresh your Context7 library when your docs change

Keep your Context7 documentation in sync by triggering a refresh whenever you push to your main branch.

## Setup

**1. Get your API key**

Go to your [Context7 dashboard](https://context7.com/dashboard?tab=settings) and copy your API key.

**2. Add the API key as a repository secret**

In your GitHub repository, go to **Settings** → **Secrets and variables** → **Actions** and add a new secret:

| Name | Value |
| - | - |
| `CONTEXT7_API_KEY` | Your API key from the Context7 dashboard |

**3. Create the workflow file**

Add the following file to your repository at `.github/workflows/context7-refresh.yml`:

```yaml theme={null}
name: Refresh Context7 Docs

on:
  push:
    branches:
      - master # change to your default branch if different

jobs:
  refresh:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger Context7 Refresh
        run: |
          curl -s -X POST https://context7.com/api/v1/refresh \
            -H "Content-Type: application/json" \
            -H "Authorization: Bearer ${{ secrets.CONTEXT7_API_KEY }}" \
            -d '{"libraryName": "/${{ github.repository }}"}'
```

This uses `${{ github.repository }}` to automatically resolve to your repository's `owner/repo` (e.g., `vercel/next.js`). If your library ID on Context7 differs from your GitHub repository name, replace it with the correct value (e.g., `/your-org/your-repo`).

## Refreshing a Specific Branch

To refresh a non-default branch, add the `branch` field to the request body. The `branch` value must match a branch name that already exists on your library in Context7.

```yaml theme={null}
- name: Trigger Context7 Refresh
  run: |
    curl -s -X POST https://context7.com/api/v1/refresh \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer ${{ secrets.CONTEXT7_API_KEY }}" \
      -d '{"libraryName": "/your-org/your-repo", "branch": "v2"}'
```

> [!NOTE]
>
> If the branch has not been added to your library on Context7, the refresh will fail with a `branch_not_found` error.

## Private Repositories

For private repositories, include a `gitToken` so Context7 can access your code:

```yaml theme={null}
- name: Trigger Context7 Refresh
  run: |
    curl -s -X POST https://context7.com/api/v1/refresh \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer ${{ secrets.CONTEXT7_API_KEY }}" \
      -d '{"libraryName": "/your-org/your-repo", "gitToken": "${{ secrets.GIT_ACCESS_TOKEN }}"}'
```

> [!NOTE]
>
> Private sources require a Pro or Enterprise plan. See the [Private Sources](https://context7.com/docs/howto/private-sources.md) guide for more details.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.