|
| 1 | +# This workflow generates the Java SDK from the Permify OpenAPI specification |
| 2 | +# It fetches the latest openapi.json from the Permify repository and runs the SDK generation script |
| 3 | + |
| 4 | +name: Generate Java SDK |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + push: |
| 11 | + paths: |
| 12 | + - 'generator/**' |
| 13 | + - '.github/workflows/generator.yml' |
| 14 | + |
| 15 | +jobs: |
| 16 | + generate: |
| 17 | + name: Generate SDK from OpenAPI |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + |
| 24 | + - name: Download OpenAPI spec from Permify repository |
| 25 | + run: | |
| 26 | + echo "Downloading latest OpenAPI specification from Permify repository..." |
| 27 | + curl -L -o generator/openapi.json https://raw.githubusercontent.com/Permify/permify/master/docs/api-reference/openapi.json |
| 28 | + |
| 29 | + - name: Check if OpenAPI spec has changed |
| 30 | + id: check_changes |
| 31 | + run: | |
| 32 | + if git diff --quiet generator/openapi.json; then |
| 33 | + echo "No changes in OpenAPI specification" |
| 34 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 35 | + else |
| 36 | + echo "OpenAPI specification has changed" |
| 37 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 38 | + fi |
| 39 | + |
| 40 | + - name: Make generate script executable |
| 41 | + if: steps.check_changes.outputs.changed == 'true' |
| 42 | + run: chmod +x generator/generate-sdk.sh |
| 43 | + |
| 44 | + - name: Generate Java SDK |
| 45 | + if: steps.check_changes.outputs.changed == 'true' |
| 46 | + run: | |
| 47 | + cd generator |
| 48 | + ./generate-sdk.sh |
| 49 | + |
| 50 | + - name: Configure Git |
| 51 | + if: steps.check_changes.outputs.changed == 'true' |
| 52 | + run: | |
| 53 | + git config --local user.email "action@github.com" |
| 54 | + git config --local user.name "GitHub Action" |
| 55 | + |
| 56 | + - name: Commit and push changes |
| 57 | + if: steps.check_changes.outputs.changed == 'true' |
| 58 | + run: | |
| 59 | + git add . |
| 60 | + git commit -m "chore: update Java SDK from latest OpenAPI specification" || exit 0 |
| 61 | + git push |
0 commit comments