What you will build
An automation that updates your documentation when code is pushed to your main branch. The workflow can be built on multiple platforms, including GitHub Actions and n8n. It watches your code repository and then calls the agent API to update your documentation in a separate documentation repository. This workflow connects two separate repositories:- Code repository: Where you store application code. You’ll set up the automation trigger on this repository. Examples include a backend API, frontend app, SDK, or CLI tool.
- Documentation repository: Where you store your documentation and connect to your Mintlify project. The agent creates pull requests with documentation updates in this repository.
Workflow overview
- Someone pushes code to your main branch.
- The workflow triggers.
- The workflow calls the agent API to update your documentation.
- The agent creates a pull request with documentation updates in your documentation repository.
Choose your platform
- GitHub Actions
- n8n
GitHub Actions is the simplest option if your code is already on GitHub. No additional services required.
Prerequisites
- GitHub Actions enabled on your code and documentation repositories
- Mintlify admin API key
- Mintlify project ID
- Mintlify Pro or Custom plan
- Admin access to the GitHub repositories for your code and documentation
Get your admin API key
- Navigate to the API keys page in your dashboard.
- Select Create Admin API Key.
- Copy the key and save it securely.
Build the workflow
Create the workflow file
-
In your code repository, create a new file:
.github/workflows/update-docs.yml -
Add this workflow:
Add secrets
- In your code repository, go to Settings → Secrets and variables → Actions.
- Click New repository secret.
- Add the following secrets:
- Name:
MINTLIFY_API_KEY, Secret: Your Mintlify admin API key - Name:
MINTLIFY_PROJECT_ID, Secret: Your Mintlify project ID (found on the API keys page of your dashboard)
- Name:
Test the automation
-
Make a small change in your code repository and push to main:
- Check the Actions tab in your code repository to see the workflow running.
- After the workflow runs, check your documentation repository for a new branch and pull request with documentation updates.
Troubleshooting
Workflow not running
- Verify GitHub Actions is enabled in your code repository.
- Check the Actions tab for error messages.
- Ensure the workflow file is in
.github/workflows/with a.ymlextension.
401 error from agent API
- Verify your API key starts with
mint_. - Check the Authorization header is formatted as
Bearer mint_yourkey. - Confirm the API key is for the correct Mintlify organization.
No documentation updates appearing
- Check that the documentation repository is connected to your Mintlify project.
- Verify the agent has write access to the documentation repository.
- Check the workflow logs for error messages from the agent.