Skip to content

Commit a8ac630

Browse files
committed
Switch to document-instance API and simplify action
Migrate the action to the new CodeForge document-instance API and simplify behavior. API client now targets /document-instance/... and returns checks_started and logs_url; token verification URL and API_BASE were adjusted. The action no longer reads or uploads a spec file, no longer supports per-SDK targeting or polling/waiting for completion, and removed related inputs (spec_path, sdk_ids, wait_for_completion, fail_on_error) and outputs (status, generation_urls, published_packages) in favor of checks_started and logs_url. README and action.yml were updated to reflect the new "document instance" terminology and GitHub Variables usage for CODEFORGE_SPEC_ID. Also bumped package version to 1.1.0 and updated code to match the simplified payload and outputs.
1 parent 6b2a25f commit a8ac630

File tree

7 files changed

+76
-302
lines changed

7 files changed

+76
-302
lines changed

README.md

Lines changed: 28 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CodeForge SDK Generation Action
22

3-
Automatically trigger SDK regeneration on [CodeForge](https://code-forge.net) when your OpenAPI specification changes.
3+
Automatically trigger SDK regeneration on [CodeForge](https://code-forge.net)
4+
when your OpenAPI specification changes.
45

56
## Quick Start
67

@@ -21,29 +22,23 @@ jobs:
2122
- name: Trigger SDK Generation
2223
uses: code-forge/generation-action@v1
2324
with:
24-
spec_id: ${{ secrets.CODEFORGE_SPEC_ID }}
25+
spec_id: 4aa2cde8-3978-4b0a-b9b8-4fef6d440e0e
2526
api_token: ${{ secrets.CODEFORGE_API_TOKEN }}
26-
spec_path: api/openapi.yaml
2727
```
2828
2929
## Inputs
3030
31-
| Input | Required | Default | Description |
32-
|-------|----------|---------|-------------|
33-
| `spec_id` | Yes | — | CodeForge spec ID (find in the platform UI) |
34-
| `api_token` | Yes | — | CodeForge API token (generate in Account Settings) |
35-
| `spec_path` | Yes | — | Path to your OpenAPI spec file in the repo (e.g. `api/openapi.yaml`) |
36-
| `sdk_ids` | No | all SDKs | Comma-separated SDK IDs to regenerate |
37-
| `wait_for_completion` | No | `true` | Wait for generation to complete before finishing the step |
38-
| `fail_on_error` | No | `true` | Fail the workflow if SDK generation fails |
31+
| Input | Required | Description |
32+
| ----------- | -------- | -------------------------------------------------------- |
33+
| `spec_id` | Yes | CodeForge document instance ID (find in the platform UI) |
34+
| `api_token` | Yes | CodeForge API token (generate in Account Settings) |
3935

4036
## Outputs
4137

42-
| Output | Description |
43-
|--------|-------------|
44-
| `status` | Generation status: `success`, `failed`, or `in_progress` |
45-
| `generation_urls` | Comma-separated URLs to view logs on CodeForge |
46-
| `published_packages` | JSON array of published package info (name, version, registry_url) |
38+
| Output | Description |
39+
| ---------------- | --------------------------------------------- |
40+
| `checks_started` | Number of generation checks that were started |
41+
| `logs_url` | URL to view generation logs on CodeForge |
4742

4843
### Using Outputs
4944

@@ -52,149 +47,48 @@ jobs:
5247
id: generate
5348
uses: code-forge/generation-action@v1
5449
with:
55-
spec_id: ${{ secrets.CODEFORGE_SPEC_ID }}
50+
spec_id: 4aa2cde8-3978-4b0a-b9b8-4fef6d440e0e
5651
api_token: ${{ secrets.CODEFORGE_API_TOKEN }}
57-
spec_path: api/openapi.yaml
5852
59-
- name: Print published packages
60-
run: echo "${{ steps.generate.outputs.published_packages }}"
53+
- name: Print logs URL
54+
run: echo "${{ steps.generate.outputs.logs_url }}"
6155
```
6256

6357
## Setup Guide
6458

65-
### 1. Get your Spec ID
59+
### 1. Get your Document Instance ID
6660

6761
1. Log in to [code-forge.net](https://code-forge.net)
68-
2. Navigate to your spec in the platform UI
69-
3. The spec ID is shown in the URL: `code-forge.net/specs/**spec_123**/...`
62+
2. Navigate to your document instance in the platform UI
63+
3. The ID is shown in the URL:
64+
`code-forge.net/platform/document-instances/**your-id**/...`
7065

7166
### 2. Generate an API Token
7267

7368
1. Go to **Account Settings** → **API Tokens**
7469
2. Click **Generate New Token**
7570
3. Copy the token (it will only be shown once)
7671

77-
### 3. Add Secrets to GitHub
72+
### 3. Add your API Token to GitHub
7873

79-
1. Go to your repository → **Settings** → **Secrets and variables** → **Actions**
80-
2. Add `CODEFORGE_SPEC_ID` with your spec ID
81-
3. Add `CODEFORGE_API_TOKEN` with your API token
82-
83-
## Examples
84-
85-
### Basic — Regenerate All SDKs
86-
87-
```yaml
88-
- uses: code-forge/generation-action@v1
89-
with:
90-
spec_id: ${{ secrets.CODEFORGE_SPEC_ID }}
91-
api_token: ${{ secrets.CODEFORGE_API_TOKEN }}
92-
spec_path: openapi.yaml
93-
```
94-
95-
### Regenerate Specific SDKs Only
96-
97-
```yaml
98-
- uses: code-forge/generation-action@v1
99-
with:
100-
spec_id: ${{ secrets.CODEFORGE_SPEC_ID }}
101-
api_token: ${{ secrets.CODEFORGE_API_TOKEN }}
102-
spec_path: openapi.yaml
103-
sdk_ids: sdk_789,sdk_012
104-
```
105-
106-
### Fire-and-Forget (Don't Wait for Completion)
107-
108-
```yaml
109-
- uses: code-forge/generation-action@v1
110-
with:
111-
spec_id: ${{ secrets.CODEFORGE_SPEC_ID }}
112-
api_token: ${{ secrets.CODEFORGE_API_TOKEN }}
113-
spec_path: openapi.yaml
114-
wait_for_completion: false
115-
```
116-
117-
### Continue Even if Generation Fails
118-
119-
```yaml
120-
- uses: code-forge/generation-action@v1
121-
with:
122-
spec_id: ${{ secrets.CODEFORGE_SPEC_ID }}
123-
api_token: ${{ secrets.CODEFORGE_API_TOKEN }}
124-
spec_path: openapi.yaml
125-
fail_on_error: false
126-
```
127-
128-
### Full Example with Multiple SDKs and Outputs
129-
130-
```yaml
131-
name: Regenerate SDKs on Spec Change
132-
133-
on:
134-
push:
135-
branches: [main]
136-
paths:
137-
- 'api/openapi.yaml'
138-
139-
jobs:
140-
generate-sdks:
141-
runs-on: ubuntu-latest
142-
steps:
143-
- uses: actions/checkout@v4
144-
145-
- name: Trigger SDK Generation
146-
id: generate
147-
uses: code-forge/generation-action@v1
148-
with:
149-
spec_id: ${{ secrets.CODEFORGE_SPEC_ID }}
150-
api_token: ${{ secrets.CODEFORGE_API_TOKEN }}
151-
spec_path: api/openapi.yaml
152-
sdk_ids: sdk_typescript,sdk_python,sdk_go
153-
wait_for_completion: true
154-
fail_on_error: true
155-
156-
- name: Print results
157-
run: |
158-
echo "Status: ${{ steps.generate.outputs.status }}"
159-
echo "Logs: ${{ steps.generate.outputs.generation_urls }}"
160-
echo "Packages: ${{ steps.generate.outputs.published_packages }}"
161-
```
74+
1. Go to your repository → **Settings** → **Secrets and variables** →
75+
**Actions**
76+
2. Under **Secrets**, add `CODEFORGE_API_TOKEN` with your API token
16277

16378
## Troubleshooting
16479

16580
### `Invalid CodeForge API token`
16681

167-
- Verify the token is correctly copied to your GitHub secret (no trailing spaces)
82+
- Verify the token is correctly copied to your GitHub secret (no trailing
83+
spaces)
16884
- Check the token hasn't expired or been revoked in Account Settings
16985
- Ensure the secret name in your workflow matches (`CODEFORGE_API_TOKEN`)
17086

171-
### `Spec not found` (404)
172-
173-
- Double-check the `spec_id` value — it should match the ID shown in the CodeForge platform URL
174-
- Confirm the API token has access to this spec
175-
176-
### `Invalid OpenAPI spec`
177-
178-
- Your `openapi.yaml` file contains validation errors
179-
- Run a local validator (e.g. `npx @redocly/cli lint openapi.yaml`) before pushing
180-
181-
### `No such file or directory` for spec_path
182-
183-
- The `spec_path` input must be relative to the repository root
184-
- Ensure the file exists and the path is correct (e.g. `api/openapi.yaml`, not `/api/openapi.yaml`)
185-
- Make sure `actions/checkout@v4` runs before this action
186-
187-
### `Generation timeout`
188-
189-
- Generation took longer than the 5-minute default polling window
190-
- Set `wait_for_completion: false` to trigger generation without waiting, and check the CodeForge platform directly
191-
- If this happens frequently, contact CodeForge support
192-
193-
### `SDK generation failed`
87+
### `Specification not found` (404)
19488

195-
- Check the `generation_urls` output for detailed logs on the CodeForge platform
196-
- Common causes: invalid spec, broken SDK configuration, or a temporary platform issue
197-
- Set `fail_on_error: false` if you want the workflow to continue regardless
89+
- Double-check the `spec_id` value — it should match the document instance ID
90+
shown in the CodeForge platform URL
91+
- Confirm the API token has access to this document instance
19892

19993
## Release Process
20094

action.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,17 @@ description: 'Automatically generate and publish SDKs when your OpenAPI spec cha
33

44
inputs:
55
spec_id:
6-
description: 'CodeForge spec ID (find in platform UI)'
6+
description: 'CodeForge document instance ID (find in platform UI)'
77
required: true
88
api_token:
99
description: 'CodeForge API token (generate in Account Settings)'
1010
required: true
11-
spec_path:
12-
description: 'Path to OpenAPI spec file in repo (e.g., api/openapi.yaml)'
13-
required: true
14-
sdk_ids:
15-
description: 'Comma-separated SDK IDs to regenerate (optional, defaults to all)'
16-
required: false
17-
wait_for_completion:
18-
description: 'Wait for generation to complete (default: true)'
19-
required: false
20-
default: 'true'
21-
fail_on_error:
22-
description: 'Fail workflow if generation fails (default: true)'
23-
required: false
24-
default: 'true'
2511

2612
outputs:
27-
status:
28-
description: 'Generation status: success | failed | in_progress'
29-
generation_urls:
30-
description: 'Comma-separated URLs to view logs on CodeForge'
31-
published_packages:
32-
description: 'JSON array of published package info'
13+
checks_started:
14+
description: 'Number of generation checks that were started'
15+
logs_url:
16+
description: 'URL to view generation logs on CodeForge'
3317

3418
runs:
3519
using: 'node20'

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
2-
"name": "codegen-action",
3-
"version": "1.0.0",
4-
"description": "GitHub Action to trigger CodeForge SDK generation when OpenAPI specs change",
5-
"main": "dist/index.js",
6-
"scripts": {
7-
"build": "ncc build src/main.ts -o dist --source-map --minify",
8-
"test": "jest"
9-
},
10-
"dependencies": {
11-
"@actions/core": "^1.10.0"
12-
},
13-
"devDependencies": {
14-
"@types/node": "^20.0.0",
15-
"@vercel/ncc": "^0.38.0",
16-
"jest": "^29.0.0",
17-
"ts-jest": "^29.0.0",
18-
"typescript": "^5.0.0"
19-
}
2+
"name": "codegen-action",
3+
"version": "1.1.0",
4+
"description": "GitHub Action to trigger CodeForge SDK generation when OpenAPI specs change",
5+
"main": "dist/index.js",
6+
"scripts": {
7+
"build": "ncc build src/main.ts -o dist --source-map --minify",
8+
"test": "jest"
9+
},
10+
"dependencies": {
11+
"@actions/core": "^1.10.0"
12+
},
13+
"devDependencies": {
14+
"@types/node": "^20.0.0",
15+
"@vercel/ncc": "^0.38.0",
16+
"jest": "^29.0.0",
17+
"ts-jest": "^29.0.0",
18+
"typescript": "^5.0.0"
19+
}
2020
}

0 commit comments

Comments
 (0)