Skip to content

Commit f6047be

Browse files
authored
Update README.md
1 parent 7c8e2c3 commit f6047be

File tree

1 file changed

+49
-9
lines changed

1 file changed

+49
-9
lines changed

README.md

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ A GitHub Action to sync files/folders from your source repository to a target re
44

55
## Usage
66

7+
### Case 1: Sync files/folders between repositories
8+
79
1. In your your source repo, create a file named `sync-openapi.yml` in `.github/workflows/`.
810
2. Include the following contents in `sync-openapi.yml`:
911

@@ -23,7 +25,7 @@ jobs:
2325
steps:
2426
- uses: actions/checkout@v4
2527
- name: Sync OpenAPI spec to target repo
26-
uses: fern-api/sync-openapi@v0
28+
uses: fern-api/sync-openapi@v2
2729
with:
2830
repository: <your-org>/<your-target-repo>
2931
token: ${{ secrets.<PAT_TOKEN_NAME> }}
@@ -43,15 +45,53 @@ jobs:
4345

4446
```
4547

48+
### Case 2: Sync specs using `fern api update`
49+
50+
1. In your your source repo, create a file named `sync-openapi.yml` in `.github/workflows/`.
51+
2. Include the following contents in `sync-openapi.yml`:
52+
53+
```yaml
54+
name: Sync OpenAPI Specs # can be customized
55+
on: # additional custom triggers can be configured, examples below
56+
workflow_dispatch: # manual dispatch
57+
push:
58+
branches:
59+
- main # on push to main
60+
schedule:
61+
- cron: '0 3 * * *' # everyday at 3:00 AM UTC
62+
63+
jobs:
64+
update-from-source:
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
with:
69+
token: ${{ secrets.OPENAPI_SYNC_TOKEN }}
70+
- name: Update API with Fern
71+
uses: fern-api/sync-openapi@v2
72+
with:
73+
update_from_source: true
74+
token: ${{ secrets.OPENAPI_SYNC_TOKEN }}
75+
branch: 'update-api'
76+
auto_merge: false # you MUST use auto_merge: true with branch: main
77+
add_timestamp: true
78+
79+
```
80+
81+
82+
4683
## Inputs
4784

48-
| Input | Description | Required | Default |
49-
|-------|-------------|----------|---------|
50-
| `repository` | Target repository in format `org/repo` | Yes | - |
51-
| `sources` | Array of mappings with from, to, and (optional) exclude fields | Yes | - |
52-
| `token` | GitHub token for authentication | No | `${{ github.token }}` |
53-
| `branch` | Branch to push to in the target repository | Yes | - |
54-
| `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` |
85+
| Input | Description | Required | Default | Case |
86+
|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------|----------|---------------------------|---------|
87+
| `token` | GitHub token for authentication | No | `${{ github.token }}` | 1, 2 |
88+
| `branch` | Branch to push to in the target repository | Yes | - | 1, 2 |
89+
| `auto_merge` | If `true`, pushes directly to the branch; if `false`, creates a PR from the branch onto `main` | No | `false` | 1, 2 |
90+
| `add_timestamp` | If `true`, appends a timestamp to the branch name | No | `true` | 1, 2 |
91+
| `sources` | Array of mappings with `from`, `to`, and optional `exclude` fields | Yes | - | 1 |
92+
| `repository` | Target repository in format `org/repo` | Yes | - | 1 |
93+
| `update_from_source`| If `true`, syncs from the source spec files rather than using existing intermediate formats | No | `false` | 2 |
94+
5595

5696
**Note: you must set `auto_merge: true` when using `branch: main`**
5797

@@ -60,7 +100,7 @@ jobs:
60100
The GitHub token used for this action must have:
61101

62102
1. **Read access** to the source repository
63-
2. **Read/Write access** to `Contents` and `Pull requests` for the target repository
103+
2. **Read/Write access** to `Contents` and `Pull requests` for the repository being updated
64104

65105
## Adding a Token for GitHub Actions
66106

0 commit comments

Comments
 (0)