A GitHub Action to sync files from your source repository to a target repository (like fern-config).
- In your your source repo, create a file named
sync-openapi.yml
in.github/workflows/
. - Include the following contents in the
sync-openapi.yml
you just created:
name: Sync OpenAPI Specs # can be customized
on:
workflow_dispatch:
push:
branches:
- main
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Sync OpenAPI spec to target repo
uses: fern-api/sync-openapi@v0
with:
repository: <your-org>/<your-target-repo>
token: ${{ secrets.<PAT_TOKEN_NAME> }}
files: |
- source: path/to/file1/in/this/repo.yml # note: all file paths are relative to repository root
destination: path/to/file1/in/destination/repo.yml
- source: path/to/file2/in/this/repo.yml
destination: path/to/file2/in/destination/repo.yml
....
branch: main
auto_merge: true # note: branch = main with auto_merge = false will cause an error
Input | Description | Required | Default |
---|---|---|---|
repository |
Target repository in format org/repo |
Yes | - |
files |
Array of mappings with source and destination paths | Yes | - |
token |
GitHub token for authentication | No | ${{ github.token }} |
branch |
Branch to push to in the target repository | Yes | - |
auto_merge |
Will push directly to the specified branch when true , will create a PR from the specified base branch onto main if false . |
No | false |
The GitHub token used for this action must have:
- Read access to the source repository
- Read/Write access to
Contents
andPull requests
for the target repository
- Generate a fine-grained https://github.com/settings/personal-access-tokens token with the above-mentioned permissions
- Go to
Settings -> Secrets and variables -> Actions
and click onNew repository secret
- Name your token (i.e.
OPENAPI_SYNC_TOKEN
) and paste in the PAT token generated above - Replace
<PAT_TOKEN_NAME>
in the example YAML configuration with your token name.