Skip to content

Commit 508e1be

Browse files
authored
Merge pull request #17 from hey-api/fix/update-inputs
feat: update action inputs
2 parents 19a9d46 + 50ee22c commit 508e1be

File tree

7 files changed

+71
-69
lines changed

7 files changed

+71
-69
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ on:
55
branches:
66
- main
77
pull_request:
8-
types:
9-
- opened
10-
- ready_for_review
11-
- reopened
12-
- synchronize
138

149
jobs:
1510
upload:
@@ -26,14 +21,14 @@ jobs:
2621
id: upload-json-openapi-spec
2722
uses: ./
2823
with:
24+
api-key: ${{ secrets.HEY_API_TOKEN }}
2925
dry-run: true
30-
hey-api-token: ${{ secrets.HEY_API_TOKEN }}
31-
path-to-openapi: ./openapi.json
26+
path-to-file: ./openapi.json
3227

3328
- name: Upload YAML OpenAPI spec
3429
id: upload-yaml-openapi-spec
3530
uses: ./
3631
with:
32+
api-key: ${{ secrets.HEY_API_TOKEN }}
3733
dry-run: true
38-
hey-api-token: ${{ secrets.HEY_API_TOKEN }}
39-
path-to-openapi: ./openapi.yaml
34+
path-to-file: ./openapi.yaml

README.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
<div align="center">
22
<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 for uploading specifications to Hey API</p>
55
</div>
66

7-
To use this action, you have to be registered with
8-
[Hey API](https://heyapi.dev/). If you don't have an account, please
9-
[email us](mailto:[email protected]) or
10-
[open an issue](https://github.com/hey-api/upload-openapi-spec/issues) and we
11-
will set you up.
7+
> Before using this GitHub Action, you must create a free account with
8+
> [Hey API](https://app.heyapi.dev/) and generate a project API key.
129
1310
## Usage
1411

15-
Create a new GitHub workflow or add an upload step to your existing workflow
12+
Create a new GitHub workflow or add an upload step to an existing workflow
1613
inside your API codebase.
1714

1815
```yaml
@@ -22,6 +19,7 @@ on:
2219
push:
2320
branches:
2421
- main
22+
pull_request:
2523

2624
jobs:
2725
upload-openapi-spec:
@@ -31,32 +29,41 @@ jobs:
3129
uses: actions/checkout@v4
3230

3331
- name: Upload OpenAPI spec
34-
uses: hey-api/upload-openapi-spec@v1
32+
uses: hey-api/upload-openapi-spec@v1.2.0
3533
with:
36-
hey-api-token: ${{ secrets.HEY_API_TOKEN }}
37-
path-to-openapi: path/to/openapi.json
34+
api-key: ${{ secrets.HEY_API_TOKEN }}
35+
path-to-file: path/to/openapi.json
36+
tags: optional,custom,tags
3837
```
3938
40-
The example above will send your OpenAPI spec to Hey API on every push to `main`
41-
branch.
39+
The example above will upload your OpenAPI specification to Hey API on every
40+
pull request and push to the `main` branch.
4241

4342
## Inputs
4443

4544
To successfully upload an OpenAPI specification, you need to provide the
4645
following inputs (see `with` in the example above)
4746

48-
### `hey-api-token`
47+
### `api-key`
4948

50-
This is the authorization token you obtained from us.
49+
This is the project API key you obtained from
50+
[Hey API](https://app.heyapi.dev/).
5151

52-
### `path-to-openapi`
52+
> Note: Personal API keys can't be used to upload specifications.
5353

54-
A relative path to your OpenAPI spec file within the repository. Note that you
55-
might need an additional step in your GitHub workflow to generate this file (see
54+
### `path-to-file`
55+
56+
A relative path to your OpenAPI file within the repository. Note that you might
57+
need an additional step in your GitHub workflow to generate this file (see
5658
[FastAPI example](https://fastapi.tiangolo.com/how-to/extending-openapi/#generate-the-openapi-schema)).
5759

60+
### `tags` (optional)
61+
62+
A comma-separated string value representing any custom tags you wish to add to
63+
your OpenAPI specification.
64+
5865
## Next Steps
5966

6067
Please follow the
61-
[integrations guide](https://heyapi.vercel.app/openapi-ts/integrations.html) on
62-
our website for the next steps.
68+
[integrations guide](https://heyapi.dev/openapi-ts/integrations) on our website
69+
for the next steps.

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ branding:
44
icon: file-plus
55
description: Upload your OpenAPI specification to Hey API
66
inputs:
7+
api-key:
8+
description: Hey API service token
9+
required: true
710
base-url:
811
description: Configure Hey API server URL
912
required: false
1013
dry-run:
1114
description: Run action in dry run mode
1215
required: false
13-
hey-api-token:
14-
description: Hey API service token
15-
required: true
16-
path-to-openapi:
16+
path-to-file:
1717
description: Input path to your OpenAPI specification file
1818
required: true
1919
tags:

dist/index.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@ import { upload } from './upload'
77
*/
88
export async function run(): Promise<void> {
99
try {
10+
const apiKey: string = core.getInput('api-key', {
11+
required: true
12+
})
13+
const baseUrl: string = core.getInput('base-url', {
14+
required: false
15+
})
1016
const dryRun: boolean =
1117
core.getInput('dry-run', {
1218
required: false
1319
}) === 'true'
14-
const baseUrl: string = core.getInput('base-url', {
15-
required: false
16-
})
17-
const heyApiToken: string = core.getInput('hey-api-token', {
18-
required: true
19-
})
20-
const pathToOpenApi: string = core.getInput('path-to-openapi', {
20+
const pathToFile: string = core.getInput('path-to-file', {
2121
required: true
2222
})
2323
const tags: string = core.getInput('tags', {
2424
required: false
2525
})
2626

27-
core.debug(`Path to OpenAPI: ${pathToOpenApi}`)
27+
core.debug(`Path to OpenAPI: ${pathToFile}`)
2828
core.debug(`Upload started: ${new Date().toTimeString()}`)
2929
await upload({
30+
apiKey,
3031
baseUrl,
3132
dryRun,
32-
heyApiToken,
33-
pathToOpenApi,
33+
pathToFile,
3434
tags
3535
})
3636
core.debug(`Upload completed: ${new Date().toTimeString()}`)

src/upload.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ import { postV1Specifications } from './client'
66
* Read and upload the provided OpenAPI specification to Hey API.
77
*/
88
export async function upload({
9+
apiKey,
910
baseUrl,
1011
dryRun,
11-
heyApiToken,
12-
pathToOpenApi,
12+
pathToFile,
1313
tags
1414
}: {
15+
/**
16+
* Hey API token.
17+
*/
18+
apiKey: string
1519
/**
1620
* Custom service url.
1721
*/
@@ -20,20 +24,16 @@ export async function upload({
2024
* Return mock response?
2125
*/
2226
dryRun?: boolean
23-
/**
24-
* Hey API token.
25-
*/
26-
heyApiToken: string
2727
/**
2828
* Path to the OpenAPI specification file.
2929
*/
30-
pathToOpenApi: string
30+
pathToFile: string
3131
/**
3232
* Custom specification tags.
3333
*/
3434
tags?: string
3535
}): Promise<void> {
36-
if (!pathToOpenApi) {
36+
if (!pathToFile) {
3737
throw new Error('invalid OpenAPI path')
3838
}
3939

@@ -51,15 +51,15 @@ export async function upload({
5151
}
5252
}
5353

54-
const specification = new Blob([fs.readFileSync(pathToOpenApi)], {
54+
const specification = new Blob([fs.readFileSync(pathToFile)], {
5555
type:
56-
pathToOpenApi.endsWith('.yaml') || pathToOpenApi.endsWith('.yaml')
56+
pathToFile.endsWith('.yaml') || pathToFile.endsWith('.yaml')
5757
? 'application/yaml'
5858
: 'application/json'
5959
})
6060

6161
const { error } = await postV1Specifications({
62-
auth: heyApiToken,
62+
auth: apiKey,
6363
baseUrl: baseUrl || 'https://api.heyapi.dev',
6464
body: {
6565
actor: process.env.GITHUB_ACTOR,

0 commit comments

Comments
 (0)