From 12062ca03cd91fb080a1900c9ffc65ef876dc048 Mon Sep 17 00:00:00 2001 From: Toli Date: Thu, 29 May 2025 10:06:28 +0100 Subject: [PATCH 1/4] add action --- validate-openapi-spectral/action.yml | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 validate-openapi-spectral/action.yml diff --git a/validate-openapi-spectral/action.yml b/validate-openapi-spectral/action.yml new file mode 100644 index 0000000..01f25df --- /dev/null +++ b/validate-openapi-spectral/action.yml @@ -0,0 +1,36 @@ +name: Validate and Publish OpenAPI Spec +description: Validates OpenAPI spec using Spectral and publishes to ReadMe +inputs: + openapi-file: + description: Path to the OpenAPI specification file + required: true + readme-api-key: + description: ReadMe API key for publishing (optional - defaults to Flipdish Readme API key) + required: false + spectral-rules: + description: Path to custom Spectral rules file (optional - defaults to Flipdish rules) + required: false +runs: + using: composite + steps: + - name: Download default Spectral rules + if: ${{ !inputs.spectral-rules }} + shell: bash + run: | + curl -o .spectral.yaml https://raw.githubusercontent.com/flipdishbytes/spectral-rules/main/.spectral.yaml + + - name: Lint OpenAPI with Spectral + uses: stoplightio/spectral-action@v0.8.11 + with: + file_glob: ${{ inputs.openapi-file }} + spectral_ruleset: ${{ inputs.spectral-rules || '.spectral.yaml' }} + + - name: Validate OpenAPI spec with ReadMe + uses: readmeio/rdme@v10 + with: + rdme: openapi validate ${{ inputs.openapi-file }} + + - name: Publish to ReadMe + uses: readmeio/rdme@v10 + with: + rdme: openapi upload ${{ inputs.openapi-file }} --key=${{ inputs.readme-api-key }} \ No newline at end of file From 2260508df96421f8254d9fd64e41cafd34d1d02f Mon Sep 17 00:00:00 2001 From: Toli Date: Thu, 29 May 2025 10:11:58 +0100 Subject: [PATCH 2/4] add dummy GHA --- .github/workflows/validate-openapi.yml | 21 +++++++++++++++++++ .../action.yml | 0 2 files changed, 21 insertions(+) create mode 100644 .github/workflows/validate-openapi.yml rename {validate-openapi-spectral => publish-openapi}/action.yml (100%) diff --git a/.github/workflows/validate-openapi.yml b/.github/workflows/validate-openapi.yml new file mode 100644 index 0000000..3891eae --- /dev/null +++ b/.github/workflows/validate-openapi.yml @@ -0,0 +1,21 @@ +name: Validate and Publish OpenAPI Spec + +on: + push: + branches: + - add-new-gha-action-for-publishing-to-readme + workflow_dispatch: # allows manual triggering + +jobs: + validate-and-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Validate and Publish OpenAPI + uses: ./.github/actions/publish-openapi + with: + openapi-file: https://api.portal.flipdish.com/menuManagement/openapi.json # Update this path to your OpenAPI spec file + readme-api-key: ${{ secrets.README_API_KEY }} + # spectral-rules: '.spectral.yaml' # Uncomment if you want to use custom rules \ No newline at end of file diff --git a/validate-openapi-spectral/action.yml b/publish-openapi/action.yml similarity index 100% rename from validate-openapi-spectral/action.yml rename to publish-openapi/action.yml From de071aa8e798ad5d4e824246a262101885428b3d Mon Sep 17 00:00:00 2001 From: Toli Date: Thu, 29 May 2025 10:15:38 +0100 Subject: [PATCH 3/4] correct path --- .github/workflows/validate-openapi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-openapi.yml b/.github/workflows/validate-openapi.yml index 3891eae..af63f0b 100644 --- a/.github/workflows/validate-openapi.yml +++ b/.github/workflows/validate-openapi.yml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v4 - name: Validate and Publish OpenAPI - uses: ./.github/actions/publish-openapi + uses: publish-openapi with: openapi-file: https://api.portal.flipdish.com/menuManagement/openapi.json # Update this path to your OpenAPI spec file readme-api-key: ${{ secrets.README_API_KEY }} From 7a41074c017472bf0f46262058bb51be3965b4e7 Mon Sep 17 00:00:00 2001 From: Toli Date: Thu, 29 May 2025 10:19:56 +0100 Subject: [PATCH 4/4] correct path --- .github/workflows/validate-openapi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-openapi.yml b/.github/workflows/validate-openapi.yml index af63f0b..c60ea4a 100644 --- a/.github/workflows/validate-openapi.yml +++ b/.github/workflows/validate-openapi.yml @@ -14,7 +14,7 @@ jobs: uses: actions/checkout@v4 - name: Validate and Publish OpenAPI - uses: publish-openapi + uses: ./publish-openapi with: openapi-file: https://api.portal.flipdish.com/menuManagement/openapi.json # Update this path to your OpenAPI spec file readme-api-key: ${{ secrets.README_API_KEY }}