forked from mongodb/docs-app-services
-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (37 loc) · 1.63 KB
/
check-openapi-data-api.yml
File metadata and controls
40 lines (37 loc) · 1.63 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
name: Check OpenAPI Spec > Data API
on:
pull_request:
paths:
- "openapi-data-api-v1/**"
- "source/data-api/openapi.txt"
env:
DEV_SPEC_FILEPATH: "openapi-data-api-v1/openapi.yaml"
BUNDLED_SPEC_FILEPATH: "source/openapi-data-api-v1.bundled.yaml"
jobs:
check-openapi-spec-data-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Verify Bundled OpenAPI File Hash
run: |
npx -y @redocly/cli@latest bundle ${{ env.DEV_SPEC_FILEPATH }} --output=latest-bundled.yaml
expected_hash=$(md5sum latest-bundled.yaml | awk '{ print $1 }')
provided_hash=$(md5sum ${{ env.BUNDLED_SPEC_FILEPATH }} | awk '{ print $1 }')
echo "expected_hash $expected_hash"
echo "provided_hash $provided_hash"
if [ "$provided_hash" != "$expected_hash" ]; then
echo "The bundled OpenAPI definition does not match the source files. Did you forget to regenerate the bundled spec?"
echo "Bundled File: ${{ env.BUNDLED_SPEC_FILEPATH }} (Hash: $provided_hash)"
echo "Source File: ${{ env.DEV_SPEC_FILEPATH }} (Bundled hash: $expected_hash)"
echo "To regenerate the spec, run this command from the repo root:"
echo ""
echo " npx @redocly/cli@latest bundle ${{ env.DEV_SPEC_FILEPATH }} --output=${{ env.BUNDLED_SPEC_FILEPATH }}"
echo ""
exit 1
fi
- name: Validate OpenAPI Spec
run: |
npx -y @redocly/cli@latest lint ${{ env.BUNDLED_SPEC_FILEPATH }} --config redocly.yaml