-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaction.yml
More file actions
102 lines (98 loc) · 3.43 KB
/
action.yml
File metadata and controls
102 lines (98 loc) · 3.43 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: "OpenAPI Diff Action"
author: "Dmitry Vasiliev"
description: "A GitHub Action to identify differences between OpenAPI specifications. It uses OpenAPITools/openapi-diff."
branding:
icon: 'check-square'
color: 'blue'
inputs:
old-spec:
description: "Old specification filename"
required: true
new-spec:
description: "New specification filename"
required: true
header:
description: "Use given header for authorization"
required: false
default: ""
query:
description: "Use query param for authorization"
required: false
default: ""
log:
description: "Use given level for log (TRACE, DEBUG, INFO, WARN, ERROR, OFF)"
required: false
default: "ERROR"
markdown:
description: "Export diff as markdown in given file"
required: false
default: ".tmp/markdown"
json:
description: "Export diff as JSON in given file"
required: false
default: ".tmp/json"
text:
description: "Export diff as text in given file"
required: false
default: '.tmp/text'
html:
description: "Export diff as HTML in given file"
required: false
default: '.tmp/html'
fail-on:
description: "Fail if API changed but is backward compatible ('changed' value) or changes broke backward compatibility ('incompatible' value)"
required: false
default: ""
outputs:
state:
description: "Output diff state: no_changes, incompatible, compatible"
value: ${{steps.state.outputs.compare_state}}
runs:
using: composite
steps:
- name: "Run openapi-diff tool"
run: |
docker run -v "$(pwd):/specs" --rm openapitools/openapi-diff:2.0.1 \
/specs/${{inputs.old-spec}} \
/specs/${{inputs.new-spec}} \
`if [[ ${{inputs.header}} != '' ]]; then --header ${{inputs.header}}; fi` \
`if [[ ${{inputs.query}} != '' ]]; then --query ${{inputs.query}}; fi` \
`if [[ ${{inputs.fail-on}} != '' ]]; then --fail-on-${{inputs.fail-on}}; fi` \
--log ${{inputs.log}} \
--markdown /specs/${{inputs.markdown}} \
--json /specs/${{inputs.json}} \
--text /specs/${{inputs.text}} \
--html /specs/${{inputs.html}}
shell: bash
- name: "Read output JSON file"
id: output_json_file
uses: juliangruber/read-file-action@v1
with:
path: ${{inputs.json}}
- name: "Detect compare state"
id: "state"
run: |
compatible_val="${{fromJson(steps.output_json_file.outputs.content).compatible}}"
incompatible_val="${{fromJson(steps.output_json_file.outputs.content).incompatible}}"
unchanged_val="${{fromJson(steps.output_json_file.outputs.content).unchanged}}"
if [[ $unchanged_val == 'true' ]]; then
echo "::set-output name=compare_state::no_changes"
elif [[ $incompatible_val == 'true' ]]; then
echo "::set-output name=compare_state::incompatible"
elif [[ $compatible_val == 'true' ]]; then
echo "::set-output name=compare_state::compatible"
fi
shell: bash
- name: "Check file existence"
id: check_files
uses: andstor/file-existence-action@v3
with:
files: ".tmp"
- name: "Post: Change folder own group"
if: steps.check_files.outputs.files_exists == 'true'
run: sudo chown -R $USER:$USER .tmp
shell: bash
- name: "Post: Remove .tmp directory"
if: steps.check_files.outputs.files_exists == 'true'
run: rm -fr .tmp
shell: bash