Skip to content

Commit 4d7b0e9

Browse files
committed
chore: allow overriding base url
1 parent 69795f9 commit 4d7b0e9

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
id: upload-yaml-openapi-spec
3535
uses: ./
3636
with:
37+
base-url: https://grouse-factual-internally.ngrok-free.app
3738
dry-run: true
3839
hey-api-token: ${{ secrets.HEY_API_TOKEN }}
3940
path-to-openapi: ./openapi.yaml

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<div align="center">
2-
<img width="150" height="150" src="https://heyapi.vercel.app/logo.png" alt="Logo">
2+
<img alt="Hey API logo" height="150" src="https://heyapi.dev/images/logo-300w.png" width="150">
33
<h1 align="center"><b>Upload OpenAPI Specification</b></h1>
4-
<p align="center">A GitHub Action that uploads your OpenAPI specifications to Hey API 🚀</p>
4+
<p align="center">🚀 A GitHub Action that uploads your OpenAPI specifications to Hey API</p>
55
</div>
66

77
To use this action, you have to be registered with
8-
[Hey API](https://heyapi.vercel.app/). If you don't have an account, please
9-
[email us](mailto:[email protected]) or
8+
[Hey API](https://heyapi.dev/). If you don't have an account, please
9+
[email us](mailto:[email protected]) or
1010
[open an issue](https://github.com/hey-api/upload-openapi-spec/issues) and we
1111
will set you up.
1212

src/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export async function run(): Promise<void> {
1111
core.getInput('dry-run', {
1212
required: false
1313
}) === 'true'
14+
const baseUrl: string = core.getInput('base-url', {
15+
required: false
16+
})
1417
const heyApiToken: string = core.getInput('hey-api-token', {
1518
required: true
1619
})
@@ -21,6 +24,7 @@ export async function run(): Promise<void> {
2124
core.debug(`Path to OpenAPI: ${pathToOpenApi}`)
2225
core.debug(`Upload started: ${new Date().toTimeString()}`)
2326
await upload({
27+
baseUrl,
2428
dryRun,
2529
heyApiToken,
2630
pathToOpenApi,

src/upload.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { readFileSync } from 'node:fs'
44
* Read and upload the provided OpenAPI specification to Hey API.
55
*/
66
export async function upload({
7+
baseUrl = 'https://platform-production-25fb.up.railway.app',
78
dryRun,
89
heyApiToken,
910
pathToOpenApi,
1011
}: {
12+
baseUrl?: string;
1113
dryRun?: boolean;
1214
/**
1315
* Hey API token.
@@ -46,17 +48,14 @@ export async function upload({
4648
)
4749
.join('&')
4850

49-
const response = await fetch(
50-
'https://platform-production-25fb.up.railway.app/api/openapi',
51-
{
52-
body,
53-
headers: {
54-
Authorization: `Bearer ${heyApiToken}`,
55-
'Content-Type': 'application/x-www-form-urlencoded'
56-
},
57-
method: 'POST'
58-
}
59-
)
51+
const response = await fetch(`${baseUrl}/v1/specs`, {
52+
body,
53+
headers: {
54+
Authorization: `Bearer ${heyApiToken}`,
55+
'Content-Type': 'multipart/form-data',
56+
},
57+
method: 'POST',
58+
});
6059

6160
if (response.status >= 300) {
6261
const error = await response.json()

0 commit comments

Comments
 (0)