|  | 
|  | 1 | +name: OpenAPI Build Documentation | 
|  | 2 | +on: | 
|  | 3 | +  push: | 
|  | 4 | +    branches: | 
|  | 5 | +      - main | 
|  | 6 | +    paths: | 
|  | 7 | +      - 'specs/swagger/**' | 
|  | 8 | +permissions: | 
|  | 9 | +  contents: write | 
|  | 10 | +jobs: | 
|  | 11 | +  lint-and-build: | 
|  | 12 | +    runs-on: ubuntu-latest | 
|  | 13 | +    steps: | 
|  | 14 | +      - name: Checkout repository | 
|  | 15 | +        uses: actions/checkout@v4 | 
|  | 16 | +        with: | 
|  | 17 | +          fetch-depth: 0  | 
|  | 18 | +      - name: Setup Node.js | 
|  | 19 | +        uses: actions/setup-node@v4 | 
|  | 20 | + | 
|  | 21 | +      - name: Install Redocly CLI | 
|  | 22 | +        run: npm install -g @redocly/cli | 
|  | 23 | + | 
|  | 24 | +      - name: Switch to gh-pages branch | 
|  | 25 | +        run: | | 
|  | 26 | +          git config --local user.email "[email protected]" | 
|  | 27 | +          git config --local user.name "GitHub Action" | 
|  | 28 | +          echo "Switching to gh-pages branch..." | 
|  | 29 | +          git checkout -b gh-pages | 
|  | 30 | +          git fetch origin gh-pages | 
|  | 31 | +          git pull --rebase origin gh-pages | 
|  | 32 | +        env: | 
|  | 33 | +          GITHUB_TOKEN: ${{ secrets.GH_SYSTEMSDT_TOKEN }} | 
|  | 34 | +      - name: Build OpenAPI documentation | 
|  | 35 | +        run: | | 
|  | 36 | +          cd specs/swagger | 
|  | 37 | +          echo "Building OpenAPI documentation..." | 
|  | 38 | +          redocly build-docs openapi.yaml --output=openapi.html | 
|  | 39 | +          echo "Documentation built successfully!" | 
|  | 40 | +       | 
|  | 41 | +      - name: Commit and push documentation | 
|  | 42 | +        run: | | 
|  | 43 | +          git config --local user.email "[email protected]" | 
|  | 44 | +          git config --local user.name "GitHub Action" | 
|  | 45 | +          echo "Committing and pushing documentation..." | 
|  | 46 | +          git add specs/swagger/openapi.html | 
|  | 47 | +          if git diff --staged --quiet; then | 
|  | 48 | +            echo "No changes to commit" | 
|  | 49 | +          else | 
|  | 50 | +            git commit -m "Update OpenAPI documentation from main branch" | 
|  | 51 | +            git push --force origin gh-pages | 
|  | 52 | +            echo "Documentation pushed to gh-pages branch!" | 
|  | 53 | +          fi | 
|  | 54 | +        env: | 
|  | 55 | +          GITHUB_TOKEN: ${{ secrets.GH_SYSTEMSDT_TOKEN }} | 
0 commit comments