Skip to content

Commit 5abd98f

Browse files
[Chore] Add CI step to validate and update OpenAPI spec (alexjustesen#2222)
Co-authored-by: Alex Justesen <[email protected]>
1 parent 69a3686 commit 5abd98f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Update OpenAPI JSON
2+
3+
on:
4+
push:
5+
paths:
6+
- 'app/Http/Controllers/Api/**/*.php'
7+
- 'app/OpenApi/**/*.php'
8+
9+
jobs:
10+
update-openapi:
11+
runs-on: ubuntu-24.04
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.event.pull_request.head.ref }}
18+
repository: ${{ github.event.pull_request.head.repo.full_name }}
19+
20+
- name: Set up PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.3'
24+
25+
- name: Install dependencies
26+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress
27+
28+
- name: Generate OpenAPI JSON
29+
run: ./vendor/bin/openapi app -o openapi_temp.json -f json
30+
31+
- name: Commit OpenAPI JSON if changed
32+
run: |
33+
if ! diff -q openapi.json openapi_temp.json; then
34+
mv openapi_temp.json openapi.json
35+
git config user.name "GitHub Action"
36+
git config user.email "[email protected]"
37+
git add openapi.json
38+
git commit -m "Update OpenAPI JSON"
39+
git push
40+
fi

0 commit comments

Comments
 (0)