forked from TheChristophe/generate-esm-api-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
85 lines (79 loc) · 2.69 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: 'Generate OpenAPI axios api client'
description: 'Generate typescript OpenAPI axios esm client using openapi-generator published to Github'
inputs:
author:
description: 'Package author'
required: true
default: 'User'
package_name:
description: 'Package name'
required: true
default: 'api-client'
spec_file:
description: "OpenAPI specification"
required: false
default: 'api-spec.json'
repo_url:
description: 'Repository url'
required: false
archive_client:
description: "Upload archive of client source"
required: false
default: "false"
license:
description: "Package license"
required: false
default: "UNLICENSED"
snapshot:
description: "Add snapshot timestamp to versions"
required: false
default: "false"
npm_registry:
description: "NPM registry"
required: false
default: "https://npm.pkg.github.com"
npm_token:
description: "NPM token (enables publishing)"
required: false
default: "false"
runs:
using: "composite"
steps:
- name: Generate client
uses: docker://openapitools/openapi-generator-cli:v6.6.0
with:
args: generate -i ${{ inputs.spec_file }} -g typescript-axios -o ./client --additional-properties=npmName=${{ inputs.package_name }} --additional-properties=npmRepository=${{ inputs.npm_registry }} --additional-properties=withSeparateModelsAndApi=true --additional-properties=modelPackage=models --additional-properties=apiPackage=apis --additional-properties=useSingleRequestParameter=true ${{ inputs.snapshot == 'true' && '--additional-properties=snapshot=true' || '' }}
- name: Sanitize client
env:
GIT_REPO_URL: ${{ inputs.repo_url }}
AUTHOR: ${{ inputs.author }}
LICENSE: ${{ inputs.license }}
run: |
sudo chown -R $USER ./client
node ${{ github.action_path }}/sanitizeGeneratedClient.mjs
shell: bash
- name: Archive client source
if: ${{ inputs.archive_client == 'true' }}
uses: actions/[email protected]
with:
name: client
path: client
- name: Cache client dependencies
if: ${{ inputs.npm_token != 'false' }}
uses: actions/setup-node@v3
with:
cache-dependency-path: ./client/package-lock.json
registry-url: ${{ inputs.npm_registry }}
node-version: '18.x'
- name: Install build dependencies
if: ${{ inputs.npm_token != 'false' }}
working-directory: ./client
run: npm install
shell: bash
- name: Publish client
if: ${{ inputs.npm_token != 'false' }}
working-directory: ./client
run: npm publish
shell: bash
env:
NODE_AUTH_TOKEN: ${{ inputs.npm_token }}