Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions hacks-and-check/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Hack and check
description: patche OpenAPI specification and check for breaking changes

inputs:
no-date-time:
description: Strip date-time fields
default: "no"
no-date:
description: Strip date fields
default: "no"
no-oneof:
description: Strip oneOf fields
default: "no"
no-properties-array:
description: inflate array's items definition
default: "no"
patch:
description: path to the OpenAPI specification patch
default: ""
input:
description: path to the input OpenAPI specification file
required: true
output:
description: path to the output OpenAPI specification file
required: true

runs:
using: composite
steps:
- name: Create temporary file
shell: bash
id: temporary
run: echo "temp-file=$(mktemp -p $(pwd) $(basename ${{ inputs.output }}.XXXXXX))" >> $GITHUB_OUTPUT

- name: Patch OpenAPI specification
uses: outscale/osc-api-deploy/hacks@main
with:
no-date-time: ${{ inputs.no-date-time }}
no-date: ${{ inputs.no-date }}
no-oneof: ${{ inputs.no-oneof }}
no-properties-array: ${{ inputs.no-properties-array }}
patch: ${{ inputs.patch }}
input: ${{ inputs.input }}
output: ${{ outputs.temporary.temp-file }}

- name: Checking breaking changes
uses: oasdiff/oasdiff-action/breaking@main
with:
base: ${{ inputs.output }}
revision: ${{ outputs.temporary.temp-file }}
fail-on: ERR

- name: Move temporary file
shell: bash
run: mv ${{ outputs.temporary.temp-file }} ${{ inputs.output }}
2 changes: 1 addition & 1 deletion hacks/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ WORKDIR /usr/src/app

COPY . .

CMD [ "./patch.rb" ]
ENTRYPOINT [ "/usr/src/app/entrypoint.sh" ]
37 changes: 37 additions & 0 deletions hacks/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Hack
description: Toolbox for patching OpenAPI specification file

inputs:
no-date-time:
description: Strip date-time fields
default: "no"
no-date:
description: Strip date fields
default: "no"
no-oneof:
description: Strip oneOf fields
default: "no"
no-properties-array:
description: inflate array's items definition
default: "no"
patch:
description: path to the OpenAPI specification patch
default: ""
input:
description: path to the input OpenAPI specification file
required: true
output:
description: path to the output OpenAPI specification file
required: true

runs:
using: docker
image: Dockerfile
args:
- ${{ inputs.no-date-time }}
- ${{ inputs.no-date }}
- ${{ inputs.no-oneof }}
- ${{ inputs.no-properties-array }}
- ${{ inputs.patch }}
- ${{ inputs.input }}
- ${{ inputs.output }}
26 changes: 26 additions & 0 deletions hacks/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/env bash

set -euxo pipefail

ARGS="--input ${6}"
if [ "${1}" = "yes" ]; then
ARGS="--nodatetime $ARGS"
fi

if [ "${2}" = "yes" ]; then
ARGS="--nodate $ARGS"
fi

if [ "${3}" = "yes" ]; then
ARGS="--nooneof $ARGS"
fi

if [ "${4}" = "yes" ]; then
ARGS="--noproperties-array $ARGS"
fi

if [ ! "${5}patch" = "patch" ]; then
ARGS="--patch ${5} $ARGS"
fi

exec /usr/src/app/patch.rb $ARGS > "${7}"