A GitHub Action to automatically sync OpenAPI Specification (OAS) files from your repository to your Brainfish API catalog. This action supports both YAML and JSON formats and automatically converts YAML files to JSON for upload.
- π Auto-sync OAS files to Brainfish catalog
- π YAML to JSON conversion - automatically converts
.yamland.ymlfiles to JSON - π Secure authentication using Brainfish API tokens
- π Flexible file paths - works with any OAS file location in your repo
- π Easy integration with GitHub workflows
- π Detailed logging for debugging and monitoring
The following inputs are fully declared and documented in the action.yml:
brainfish_api_token[Required] - Your Brainfish API token for authenticationcatalog_id[Required] - The Brainfish catalog ID where the OAS file should be uploadedoas_file_path[Required] - Path to your OpenAPI Specification file (supports.yaml,.yml,.json)
github_token[Optional] - GitHub token (automatically provided, required only for private repositories)
status- The status of the OAS sync operationuploaded_file- The name of the file that was uploaded to Brainfish
name: Sync OAS to Brainfish
on:
push:
branches: [main]
paths: ['docs/api.yaml'] # Only run when OAS file changes
jobs:
sync-oas:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Sync OAS to Brainfish
uses: brainfish-ai/brainfish-oas-sync@v1
with:
brainfish_api_token: ${{ secrets.BRAINFISH_API_TOKEN }}
catalog_id: ${{ secrets.BRAINFISH_CATALOG_ID }}
oas_file_path: 'docs/api.yaml'name: Sync OAS on Release
on:
release:
types: [published]
jobs:
sync-oas:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Sync OpenAPI Spec to Brainfish
uses: brainfish-ai/brainfish-oas-sync@v1
with:
brainfish_api_token: ${{ secrets.BRAINFISH_API_TOKEN }}
catalog_id: 'your-catalog-id'
oas_file_path: 'openapi.json'name: Sync Multiple OAS Files
on:
workflow_dispatch: # Manual trigger
jobs:
sync-multiple-oas:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- file: 'docs/user-api.yaml'
catalog: 'user-api-catalog-id'
- file: 'docs/admin-api.yml'
catalog: 'admin-api-catalog-id'
- file: 'docs/public-api.json'
catalog: 'public-api-catalog-id'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Sync ${{ matrix.file }} to Brainfish
uses: brainfish-ai/brainfish-oas-sync@v1
with:
brainfish_api_token: ${{ secrets.BRAINFISH_API_TOKEN }}
catalog_id: ${{ matrix.catalog }}
oas_file_path: ${{ matrix.file }}- Log in to your Brainfish dashboard
- Navigate to API settings
- Generate a new API token
- Copy the token for use in GitHub secrets
- In your Brainfish dashboard, go to your desired catalog
- Copy the catalog ID from the URL or catalog settings
Add the following secrets to your GitHub repository:
BRAINFISH_API_TOKEN- Your Brainfish API tokenBRAINFISH_CATALOG_ID- Your catalog ID (optional, can be hardcoded in workflow)
Create .github/workflows/sync-oas.yml with one of the examples above.
| Format | Extension | Conversion | Status |
|---|---|---|---|
| YAML | .yaml |
β Auto-convert to JSON | β Supported |
| YAML | .yml |
β Auto-convert to JSON | β Supported |
| JSON | .json |
β‘ Upload as-is | β Supported |
The action provides detailed error messages for common issues:
- File not found: Check your
oas_file_pathparameter - Invalid YAML/JSON: Validate your OAS file syntax
- Authentication failed: Verify your
brainfish_api_token - Catalog not found: Check your
catalog_id - Network errors: Temporary issues with Brainfish API
-
"OAS file not found"
- Verify the file path is correct and the file exists
- Use relative paths from the repository root
-
"Authentication failed"
- Check that your API token is valid and not expired
- Ensure the token has proper permissions for the catalog
-
"Invalid YAML format"
- Validate your YAML syntax using a YAML validator
- Check for proper indentation and structure
Enable debug logging by adding this to your workflow:
env:
ACTIONS_STEP_DEBUG: trueIf you're contributing to this action or need to build it locally:
-
Install dependencies
npm install
-
Build the action
npm run build
-
Test locally (optional)
# Create a test OAS file echo 'openapi: "3.0.0"' > test-api.yaml # Set environment variables export INPUT_BRAINFISH_API_TOKEN="your-token" export INPUT_CATALOG_ID="your-catalog-id" export INPUT_OAS_FILE_PATH="test-api.yaml" # Run the action node index.js
- Fork the repository
- Create a feature branch
- Make your changes
- Run
npm run buildto update thedist/folder - Submit a pull request
This project is licensed under the MIT License - see the repository for details.
- π Brainfish Documentation
- π Report Issues
- π¬ Community Support