Update generate-schema.yml #157
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build specifications, schemas and comparisions | |
| on: | |
| push: | |
| workflow_dispatch: | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| skip_job: ${{ steps.skip.outputs.skip_job }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Check last commit message | |
| id: commit-message | |
| run: | | |
| echo "COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s')" >> "$GITHUB_ENV" | |
| echo "skip_job=false" >> "$GITHUB_OUTPUT" | |
| - id: skip | |
| name: Skip if automated push | |
| if: contains(env.COMMIT_MESSAGE, 'Apply automatic changes') | |
| run: | | |
| echo "Automated commit detected - skipping job" | |
| echo "skip_job=true" >> "$GITHUB_OUTPUT" | |
| - name: Check Branch with Regex | |
| id: check-tag | |
| run: | | |
| regex="^refs/heads/brapi-V[0-9]+\.[0-9]+$" | |
| if [[ "${{ github.ref }}" =~ $regex ]]; then | |
| echo "commit=true" >> $GITHUB_ENV | |
| else | |
| echo "commit=false" >> $GITHUB_ENV | |
| fi | |
| if [[ $commit == 'true']]; then | |
| echo "Release branch - will commit generated files" | |
| else | |
| echo "Feature branch - will NOT commit generated files" | |
| fi | |
| generate: | |
| runs-on: ubuntu-latest | |
| needs: check | |
| if: needs.check.outputs.skip_job != 'true' | |
| steps: | |
| - name: debug | |
| run: echo ${{ needs.check.outputs.skip_job }} | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ssh-key: ${{ secrets.DEPLOY_KEY }} | |
| - name: Set up Docker Compose | |
| uses: docker/setup-compose-action@v1 | |
| - name: Build and run the Docker image | |
| working-directory: ./docker | |
| run: docker compose run build-docs | |
| - name: Convert compiled specification | |
| working-directory: ./docker | |
| run: docker compose run gen-swagger | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '22' | |
| distribution: 'temurin' | |
| - name: Change wrapper permissions | |
| working-directory: ./generator | |
| run: chmod +x ./gradlew | |
| - name: Copy compiled specification | |
| working-directory: ./generator | |
| run: ./gradlew copyOpenApi | |
| - name: Validate | |
| working-directory: ./generator | |
| run: ./gradlew validate | |
| - name: Generate OpenAPI, GraphQL and OWL | |
| working-directory: ./generator | |
| run: ./gradlew generateAll | |
| - name: Compare OpenAPI | |
| working-directory: ./generator | |
| run: ./gradlew compareAll | |
| - if: env.commit == 'true' | |
| uses: stefanzweifel/git-auto-commit-action@v5 |