# Validate and publish OpenAPI specs to RapidAPI when apis/*/openapi.yaml changes on main. # Requires secrets (configured once RapidAPI listings are live): # RAPIDAPI_PLATFORM_KEY, RAPIDAPI_ZIP_API_ID, RAPIDAPI_ZIP_VERSION_ID, # RAPIDAPI_HOLIDAYS_API_ID, RAPIDAPI_HOLIDAYS_VERSION_ID, # RAPIDAPI_AQI_API_ID, RAPIDAPI_AQI_VERSION_ID # # If RAPIDAPI_PLATFORM_KEY is not set the publish step exits 0 with a skip message. name: Validate and Publish OpenAPI Specs on: push: branches: - main paths: - 'apis/*/openapi.yaml' jobs: publish: name: Lint and publish specs runs-on: ubuntu-latest steps: - name: Checkout (with history for diff) uses: actions/checkout@v4 with: fetch-depth: 2 - name: Set up Node.js 20 uses: actions/setup-node@v4 with: node-version: '20' - name: Install Redocly CLI run: npm install -g @redocly/cli@latest - name: Lint OpenAPI specs run: | echo "Linting all OpenAPI specs..." npx @redocly/cli lint apis/*/openapi.yaml - name: Detect changed specs id: changed run: | changed=$(git diff --name-only HEAD~1 HEAD | grep 'openapi\.yaml' || true) echo "Changed specs: ${changed:-none}" echo "files=${changed}" >> "$GITHUB_OUTPUT" - name: Publish specs to RapidAPI env: RAPIDAPI_KEY: ${{ secrets.RAPIDAPI_PLATFORM_KEY }} RAPIDAPI_ZIP_API_ID: ${{ secrets.RAPIDAPI_ZIP_API_ID }} RAPIDAPI_ZIP_VERSION_ID: ${{ secrets.RAPIDAPI_ZIP_VERSION_ID }} RAPIDAPI_HOLIDAYS_API_ID: ${{ secrets.RAPIDAPI_HOLIDAYS_API_ID }} RAPIDAPI_HOLIDAYS_VERSION_ID: ${{ secrets.RAPIDAPI_HOLIDAYS_VERSION_ID }} RAPIDAPI_AQI_API_ID: ${{ secrets.RAPIDAPI_AQI_API_ID }} RAPIDAPI_AQI_VERSION_ID: ${{ secrets.RAPIDAPI_AQI_VERSION_ID }} run: node scripts/publish-openapi.js