Skip to content

Commit 8abf97e

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

File tree

4 files changed

+119
-1
lines changed

4 files changed

+119
-1
lines changed

hacks-and-check/action.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Hack and check
2+
description: patche OpenAPI specification and check for breaking changes
3+
4+
inputs:
5+
no-date-time:
6+
description: Strip date-time fields
7+
default: "no"
8+
no-date:
9+
description: Strip date fields
10+
default: "no"
11+
no-oneof:
12+
description: Strip oneOf fields
13+
default: "no"
14+
no-properties-array:
15+
description: inflate array's items definition
16+
default: "no"
17+
patch:
18+
description: path to the OpenAPI specification patch
19+
default: ""
20+
input:
21+
description: path to the input OpenAPI specification file
22+
required: true
23+
output:
24+
description: path to the output OpenAPI specification file
25+
required: true
26+
27+
runs:
28+
using: composite
29+
steps:
30+
- name: Create temporary file
31+
shell: bash
32+
id: temporary
33+
run: echo "temp-file=$(mktemp -p $(pwd) $(basename ${{ inputs.output }}.XXXXXX))" >> $GITHUB_OUTPUT
34+
35+
- name: Patch OpenAPI specification
36+
uses: outscale/osc-api-deploy/hacks@main
37+
with:
38+
no-date-time: ${{ inputs.no-date-time }}
39+
no-date: ${{ inputs.no-date }}
40+
no-oneof: ${{ inputs.no-oneof }}
41+
no-properties-array: ${{ inputs.no-properties-array }}
42+
patch: ${{ inputs.patch }}
43+
input: ${{ inputs.input }}
44+
output: ${{ outputs.temporary.temp-file }}
45+
46+
- name: Checking breaking changes
47+
uses: oasdiff/oasdiff-action/breaking@main
48+
with:
49+
base: ${{ inputs.output }}
50+
revision: ${{ outputs.temporary.temp-file }}
51+
fail-on: ERR
52+
53+
- name: Move temporary file
54+
shell: bash
55+
run: mv ${{ outputs.temporary.temp-file }} ${{ inputs.output }}

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