1
1
name : " Generate and upload openAPI docs"
2
- description : " Generate and upload openAPI docs"
2
+ description : " Generate and upload openAPI docs using Redocly CLI "
3
3
branding :
4
4
icon : " globe"
5
5
color : " gray-dark"
6
-
7
6
inputs :
8
7
output :
9
8
description : " openAPI output file"
@@ -13,34 +12,119 @@ inputs:
13
12
description : " Input file to use to generate openAPI docs"
14
13
required : true
15
14
default : " "
15
+ validate :
16
+ description : " Validate OpenAPI spec before generating docs"
17
+ required : false
18
+ default : " true"
19
+ redocly-version :
20
+ description : " Version of Redocly CLI to use"
21
+ required : false
22
+ default : " latest"
23
+ config :
24
+ description : " Path to the Redocly config file for linting"
25
+ required : false
26
+ node-version :
27
+ description : " Node.js version to use"
28
+ required : false
29
+ default : " 22"
30
+ retention-days :
31
+ description : " Number of days to retain the artifact"
32
+ required : false
33
+ default : " 90"
16
34
17
35
runs :
18
36
using : " composite"
19
37
steps :
20
- # # checkout the code
21
38
- name : Checkout the latest code
22
39
id : git_checkout
23
40
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24
41
25
- # # Use redoc to generate HTML of openapi.yml
26
- - name : Redoc
42
+ - name : Detect OpenAPI spec version
43
+ id : detect_spec
44
+ shell : bash
45
+ run : |
46
+ echo "Detecting if new Redocly-based spec exists..."
47
+ if [ -f ./docs/rpc/redocly.yaml ]; then
48
+ echo "use_redocly_cli=true" >> "$GITHUB_OUTPUT"
49
+ echo "✅ Detected new Redocly spec"
50
+ else
51
+ echo "use_redocly_cli=false" >> "$GITHUB_OUTPUT"
52
+ echo "ℹ️ Falling back to legacy Redoc flow"
53
+ fi
54
+
55
+ - name : Setup Node.js
56
+ if : steps.detect_spec.outputs.use_redocly_cli == 'true'
57
+ uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
58
+ with :
59
+ node-version : " ${{ inputs.node-version }}"
60
+
61
+ - name : Install Redocly CLI
62
+ if : steps.detect_spec.outputs.use_redocly_cli == 'true'
63
+ id : install_redocly
64
+ shell : bash
65
+ run : |
66
+ npm install -g @redocly/cli@${{ inputs.redocly-version }}
67
+ echo "✅ Redocly CLI version: $(redocly --version)"
68
+
69
+ - name : Validate OpenAPI spec
70
+ if : inputs.validate == 'true' && steps.detect_spec.outputs.use_redocly_cli == 'true'
71
+ id : validate_spec
72
+ shell : bash
73
+ run : |
74
+ echo "Validating OpenAPI specification..."
75
+ CONFIG_ARG=""
76
+ if [ -n "${{ inputs.config }}" ]; then
77
+ CONFIG_ARG="--config ${{ inputs.config }}"
78
+ fi
79
+ redocly lint ${{ inputs.input }} $CONFIG_ARG
80
+ echo "✅ OpenAPI specification is valid"
81
+
82
+ - name : Generate OpenAPI docs
83
+ if : steps.detect_spec.outputs.use_redocly_cli == 'true'
84
+ id : generate_docs
85
+ shell : bash
86
+ run : |
87
+ echo "Generating OpenAPI documentation..."
88
+ CONFIG_ARG=""
89
+ if [ -n "${{ inputs.config }}" ]; then
90
+ CONFIG_ARG="--config ${{ inputs.config }}"
91
+ fi
92
+ redocly build-docs ${{ inputs.input }} --output ${{ inputs.output }} $CONFIG_ARG
93
+ echo "✅ Documentation generated successfully"
94
+
95
+ - name : Check result
96
+ if : steps.detect_spec.outputs.use_redocly_cli == 'true'
97
+ id : check_result
98
+ shell : bash
99
+ run : |
100
+ echo "Checking if documentation file exists..."
101
+ if [ ! -f ${{ inputs.output }} ]; then
102
+ echo "❌ Missing ${{ inputs.output }} from previous step."
103
+ exit 1
104
+ fi
105
+ echo "✅ Generated documentation file is valid"
106
+ echo "📄 File size: $(du -h ${{ inputs.output }} | cut -f1)"
107
+
108
+ - name : Redoc (legacy)
27
109
id : run_redoc
110
+ if : steps.detect_spec.outputs.use_redocly_cli == 'false'
28
111
uses : seeebiii/redoc-cli-github-action@c9649b33918da5eb290b81cd03a943caea091540 # v10
29
112
with :
30
113
args : " bundle -o ${{ inputs.output }} ${{ inputs.input }}"
31
114
32
- # # Test the resultant html
33
- - name : check result
115
+ - name : Check result (legacy)
34
116
id : check_redoc
117
+ if : steps.detect_spec.outputs.use_redocly_cli == 'false'
35
118
shell : bash
36
119
run : |
37
120
test -f ${{ inputs.output }} || (echo "Missing ${{ inputs.output }} from previous step." && exit 1)
38
121
39
122
# # Upload the html file artifact
40
123
- name : Upload bundled html
41
124
id : upload_html_artifact
42
- uses : actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
125
+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
43
126
with :
44
127
name : open-api-bundle
45
128
path : |
46
129
${{ inputs.output }}
130
+ retention-days : ${{ inputs.retention-days }}
0 commit comments