Skip to content

Commit f88dc7c

Browse files
committed
Add generation workflow
0 parents  commit f88dc7c

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

.github/workflows/generate.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Generate
2+
3+
on:
4+
repository_dispatch:
5+
types: [spec-updated]
6+
workflow_dispatch:
7+
schedule:
8+
- cron: '0 2 * * *' # Daily check at 2 AM
9+
10+
jobs:
11+
generate:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout wrapper repo
15+
uses: actions/checkout@v3
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
19+
- name: Download OpenAPI spec
20+
run: |
21+
curl -o spec.yaml https://raw.githubusercontent.com/BuiltByBit/api-openapi-spec/main/spec.yaml
22+
23+
- name: Setup Java
24+
uses: actions/setup-java@v3
25+
with:
26+
distribution: 'temurin'
27+
java-version: '11'
28+
29+
- name: Download OpenAPI Generator
30+
run: |
31+
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.2.0/openapi-generator-cli-7.2.0.jar -O openapi-generator-cli.jar
32+
33+
- name: Generate PHP wrapper
34+
run: |
35+
rm -rf generated/*
36+
java -jar openapi-generator-cli.jar generate \
37+
-i spec.yaml \
38+
-g php \
39+
-o generated/ \
40+
--skip-validate-spec \
41+
--git-repo-id api-wrapper-codegen-php \
42+
--git-user-id BuiltByBit \
43+
--additional-properties="packageName=YourApiClient"
44+
45+
- name: Copy generated files
46+
run: |
47+
# Copy generated files to repo root, preserving structure
48+
rsync -av generated/ ./ --exclude=generated
49+
50+
- name: Check for changes
51+
id: changes
52+
run: |
53+
if git diff --quiet; then
54+
echo "has-changes=false" >> $GITHUB_OUTPUT
55+
else
56+
echo "has-changes=true" >> $GITHUB_OUTPUT
57+
fi
58+
59+
- name: Commit and push changes
60+
if: steps.changes.outputs.has-changes == 'true'
61+
run: |
62+
git config --local user.email "action@github.com"
63+
git config --local user.name "GitHub Action"
64+
# Add only specific directories/files, not everything
65+
git add lib/ docs/ src/ composer.json README.md
66+
git commit -m "Auto-generate wrapper from updated spec"
67+
git push

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# OpenAPI Generator
2+
openapi-generator-cli*.jar
3+
spec.yaml
4+
5+
# Generated build artifacts
6+
.openapi-generator/

0 commit comments

Comments
 (0)