Merge pull request #6843 from devtron-labs/specs-main-cut #46
  
    
      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: API Specs Merger | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'specs/**' | |
| permissions: | |
| contents: write | |
| jobs: | |
| lint-bundle-host: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Set up Redocly CLI | |
| run: npm install -g @redocly/cli | |
| - name: Run specs bundling script | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| chmod +x scripts/generate-api-docs.sh | |
| ./scripts/generate-api-docs.sh | |
| - name: Commit and push documentation | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_SYSTEMSDT_TOKEN }} | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| # Fetch the gh-pages branch | |
| git fetch origin gh-pages | |
| # Create a separate worktree for the branch | |
| git worktree add /tmp/gh-pages gh-pages | |
| # Copy generated docs into the worktree | |
| mkdir -p /tmp/gh-pages/docs/api-docs | |
| cp -r docs/api-docs/* /tmp/gh-pages/docs/api-docs/ || true | |
| cd /tmp/gh-pages | |
| git add . | |
| if git diff --staged --quiet; then | |
| echo "✅ No changes to commit" | |
| else | |
| git commit -m "📄 Update API documentation" | |
| git push origin gh-pages | |
| echo "🚀 Documentation pushed to gh-pages branch!" | |
| fi | |