Skip to content

Commit fe0039e

Browse files
committed
✨ feat: add GitHub actions support for hacks
1 parent ab804a1 commit fe0039e

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

hacks/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ WORKDIR /usr/src/app
44

55
COPY . .
66

7-
CMD [ "./patch.rb" ]
7+
ENTRYPOINT [ "/usr/src/app/entrypoint.sh" ]

hacks/action.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Hack
2+
description: Toolbox for patching OpenAPI specification file
3+
author: Outscale SAS
4+
5+
inputs:
6+
no-date-time:
7+
description: Strip date-time fields
8+
default: "no"
9+
no-date:
10+
description: Strip date fields
11+
default: "no"
12+
no-oneof:
13+
description: Strip oneOf fields
14+
default: "no"
15+
no-properties-array:
16+
description: inflate array's items definition
17+
default: "no"
18+
patch:
19+
description: path to the OpenAPI specification patch
20+
default: ""
21+
input:
22+
description: path to the input OpenAPI specification file
23+
required: true
24+
output:
25+
description: path to the output OpenAPI specification file
26+
required: true
27+
28+
runs:
29+
using: docker
30+
image: Dockerfile
31+
args:
32+
- ${{ inputs.no-date-time }}
33+
- ${{ inputs.no-date }}
34+
- ${{ inputs.no-oneof }}
35+
- ${{ inputs.no-properties-array }}
36+
- ${{ inputs.patch }}
37+
- ${{ inputs.input }}
38+
- ${{ inputs.output }}

hacks/entrypoint.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
ARGS="--input ${6}"
6+
if [ "${1}" = "yes" ]; then
7+
ARGS="--nodatetime $ARGS"
8+
fi
9+
10+
if [ "${2}" = "yes" ]; then
11+
ARGS="--nodate $ARGS"
12+
fi
13+
14+
if [ "${3}" = "yes" ]; then
15+
ARGS="--nooneof $ARGS"
16+
fi
17+
18+
if [ "${4}" = "yes" ]; then
19+
ARGS="--noproperties-array $ARGS"
20+
fi
21+
22+
if [ ! "${5}patch" = "patch" ]; then
23+
ARGS="--patch ${5} $ARGS"
24+
fi
25+
26+
exec /usr/src/app/patch.rb $ARGS > "${7}"

0 commit comments

Comments
 (0)