-
Notifications
You must be signed in to change notification settings - Fork 5
65 lines (57 loc) · 2.83 KB
/
verify-openapi.yml
File metadata and controls
65 lines (57 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: verify openapi versions
on:
workflow_call:
jobs:
prepare-api-groups:
runs-on: ubuntu-latest
outputs:
api_groups: ${{ steps.outputStep.outputs.matrix }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: eclipse-edc/.github/.github/actions/setup-build@main
- run: ./gradlew resolve
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- uses: eclipse-edc/.github/.github/actions/setup-build@main
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: openapi-spec
path: resources/openapi/yaml
- run: |
CHANGELOG=$(git diff-tree --name-only HEAD..origin/main -r)
JSON_VERSION_FILE=$(cat ${{ env.versionFile }})
if (echo $CHANGELOG | grep -q "$JSON_VERSION_FILE") ; then
echo "Version file for context ${{ matrix.apiGroup }} has been modified, no need to check differences"
exit 0
fi
VERSION=$(cat $JSON_VERSION_FILE | jq '.[] | select(.maturity=="stable" or .maturity==null) | .version' | cut -d '"' -f 2)
./gradlew mergeOpenApiSpec --inputDir=${PWD}/resources/openapi/yaml/${{ matrix.apiGroup }} --output=${{ matrix.apiGroup }}-new.yaml --infoTitle="${{ matrix.apiGroup }}" --infoDescription="REST API documentation for the ${{ matrix.apiGroup }}" --infoVersion=$VERSION
git show origin/gh-pages:openapi/${{ matrix.apiGroup }}/${{ matrix.apiGroup }}.yaml > ${{ matrix.apiGroup }}.yaml
diff ${{ matrix.apiGroup }}.yaml ${{ matrix.apiGroup }}-new.yaml > diff
echo "diff with the current version"
cat diff
if [ -s diff ]; then
echo "${{ matrix.apiGroup }} openapi spec diverges from the published one, please update the version.json file";
exit 1;
fi