CI/CD Integration
drift is designed to run in your CI/CD pipeline, catching documentation drift before code gets merged. While you can run it locally, automating intelligent reviews on every Pull Request is incredibly powerful.
GitHub Action
We provide an official GitHub Action for seamless integration.
Basic Usage
For detailed setup instructions, please see the action’s README . The foundational approach is to run drift check against your entire repository:
name: Drift Check
on: [pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Drift
uses: driftee-ai/drift-action@v1
with:
# Ensure your API key is stored in GitHub Secrets
gemini-api-key: ${{ secrets.GEMINI_API_KEY }}Optimized Usage (Recommended)
Running drift on the entire codebase for every small PR is inefficient and can consume unnecessary LLM tokens. We strongly recommend configuring the action to check only changed files.
When you pass the changed-files input, drift will:
- Filter your rules to find only those affected by the changes.
- Only assess the code/docs that are actually “in play” for this PR.
Option 1: Using tj-actions/changed-files (Easiest)
We recommend using the robust tj-actions/changed-files action to reliably detect changes.
name: Drift Check
on: [pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# 1. Detect changed files
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
separator: ","
# 2. Pass them to Drift
- name: Run Drift
uses: driftee-ai/drift-action@v1
with:
gemini-api-key: ${{ secrets.GEMINI_API_KEY }}
changed-files: ${{ steps.changed-files.outputs.all_changed_files }}
diff-only: true # Recommended: Only fail if the PR caused the drift(Note: The drift check CLI strictly requires diff contents via the --diff flag when --diff-only is used. However, the drift-action intelligently handles this for you by running git diff under the hood!)
Option 2: Using Native Git (No Dependencies)
If you prefer not to add external dependencies, you can use native git commands to find the difference between the PR branch and the target branch.
name: Drift Check
on: [pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to fetch history for git diff
- name: Run Drift
uses: driftee-ai/drift-action@v1
env:
# Compare HEAD against the base branch (usually origin/main)
CHANGED_FILES: $(git diff --name-only origin/${{ github.base_ref }}...HEAD | tr '\n' ',')
with:
gemini-api-key: ${{ secrets.GEMINI_API_KEY }}
changed-files: ${{ env.CHANGED_FILES }}Behavior on Drift
When the action detects drift:
- It will log the specific reason why the code and docs are out of sync (provided by the LLM).
- It will exit with a failure code, which will flag the check as “failed” on your Pull Request.
This doesn’t strictly prevent merging (unless you configure it as a required check in GitHub settings), but it serves as a strong signal to the reviewer that the documentation needs attention.
Status Badge
Let your users know that your documentation is always perfectly in sync by adding a Drift status badge to your README.md.
Assuming your Drift workflow is named drift.yml (like the examples above) and is located at .github/workflows/drift.yml, you can add this snippet to your repository:
[](https://github.com/your-username/your-repo/actions/workflows/drift.yml)