name: Manual build API example

on:
  pull_request:
    paths:
      - ".github/workflows/example-build.yml"
      - "examples/**"
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  local-ci:
    name: Example app
    runs-on: ubuntu-22.04

    steps:
      - uses: actions/checkout@v6

      - name: Start containers
        run: docker compose up -d --build
        working-directory: "./examples/booking"

      # Runs positive Schemathesis tests
      - uses: schemathesis/action@v2
        continue-on-error: true
        with:
          # A local API schema location
          schema: "http://127.0.0.1:8080/openapi.json"
          max-examples: "10"
          # To avoid failing the build
          args: "--include-path does-not-exist"

      - name: Stop containers
        if: always()
        run: docker compose down
        working-directory: "./examples/booking"
