Skip to content

Commit

Permalink
use reusable flow to verify openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jun 20, 2024
1 parent 62ae5d6 commit 7dfa26b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 66 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/publish-openapi-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ on:
push:
branches:
- main
workflow_dispatch:
inputs:
version:
description: version to be published
required: false
type: string

jobs:
publish:
Expand Down
63 changes: 3 additions & 60 deletions .github/workflows/verify-management-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,6 @@ on:
pull_request:

jobs:
prepare-api-groups:
runs-on: ubuntu-latest
outputs:
api_groups: ${{ steps.outputStep.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: eclipse-edc/.github/.github/actions/setup-build@main
- run: ./gradlew resolve
- uses: actions/upload-artifact@v4
with:
name: openapi-spec
path: resources/openapi/yaml
- name: get api groups to verify and create matrix for next job
id: outputStep
run: |
if test -d resources/openapi/yaml; then
API_GROUPS_ARRAY=$(ls -l resources/openapi/*.version | awk '{print $9}' | awk -F "[/\.]" '{print $3}' | sed ':a; N; $!ba; s/\n/","/g' | sed 's/.*/["&"]/')
echo "matrix={\"apiGroup\": ${API_GROUPS_ARRAY}}" >> $GITHUB_OUTPUT
fi
verify-spec:
if: ${{ needs.prepare-api-groups.outputs.api_groups != '' }}
needs: prepare-api-groups
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.prepare-api-groups.outputs.api_groups) }}
env:
versionFile: resources/openapi/${{ matrix.apiGroup }}.version
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: eclipse-edc/.github/.github/actions/setup-build@main
- uses: actions/download-artifact@v4
with:
name: openapi-spec
path: resources/openapi/yaml
- run: |
CHANGELOG=$(git diff-tree --name-only HEAD..origin/main -r)
if (echo $CHANGELOG | grep -q "${{ env.versionFile }}") ; then
echo "Version file for context ${{ matrix.apiGroup }} has been modified, no need to check differences"
echo "skip=true" >> $GITHUB_OUTPUT
fi
- if: ( steps.verify-spec.outputs.skip != 'true' )
run: |
VERSION=$(cat ${{ env.versionFile }} | xargs cat | grep version | awk -F '"' '{print $4}')
./gradlew -Pversion=$VERSION -PapiTitle="${{ matrix.apiGroup }}" -PapiDescription="REST API documentation for the ${{ matrix.apiGroup }}" :mergeApiSpec --input=resources/openapi/yaml/${{ matrix.apiGroup }} --output=${{ matrix.apiGroup }}-new.yaml
git show origin/gh-pages:openapi/${{ matrix.apiGroup }}/${{ matrix.apiGroup }}.yaml > ${{ matrix.apiGroup }}.yaml
diff ${{ matrix.apiGroup }}.yaml ${{ matrix.apiGroup }}-new.yaml > diff
if [ -s diff ]; then
echo "${{ matrix.apiGroup }} openapi spec diverges from the published one, please update the version.json file"
cat diff
exit 1
fi
publish:
uses: eclipse-edc/.github/.github/workflows/verify-openapi.yml@main
secrets: inherit

0 comments on commit 7dfa26b

Please sign in to comment.