|
| 1 | +name: Docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'docs/**' |
| 8 | + - 'skills/**' |
| 9 | + - 'agents/**' |
| 10 | + - 'commands/**' |
| 11 | + - 'README.md' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: docs-deploy |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-and-deploy: |
| 23 | + name: Build and Deploy Docs |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 28 | + |
| 29 | + - name: Setup Bun |
| 30 | + uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2 |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: bun install --frozen-lockfile |
| 34 | + |
| 35 | + - name: Generate reference content |
| 36 | + run: bun run docs:generate |
| 37 | + |
| 38 | + - name: Build docs |
| 39 | + run: bun run --cwd docs build |
| 40 | + |
| 41 | + - name: Create GitHub App token |
| 42 | + if: github.repository == 'marcusrbrown/systematic' |
| 43 | + uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1 |
| 44 | + id: app-token |
| 45 | + with: |
| 46 | + app-id: ${{ secrets.FRO_BOT_APPLICATION_ID }} |
| 47 | + private-key: ${{ secrets.FRO_BOT_APPLICATION_PRIVATE_KEY }} |
| 48 | + owner: fro-bot |
| 49 | + |
| 50 | + - name: Deploy to fro-bot/systematic |
| 51 | + if: github.repository == 'marcusrbrown/systematic' |
| 52 | + env: |
| 53 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 54 | + APP_SLUG: ${{ steps.app-token.outputs.app-slug }} |
| 55 | + run: | |
| 56 | + name="${APP_SLUG}[bot]" |
| 57 | + user_id=$(gh api "/users/${name}" --jq .id) |
| 58 | + email="${user_id}+${name}@users.noreply.github.com" |
| 59 | + git config --global user.email "${email}" |
| 60 | + git config --global user.name "${name}" |
| 61 | +
|
| 62 | + # Verify docs build output exists |
| 63 | + if [ ! -d "docs/dist" ]; then |
| 64 | + echo "✗ Docs build output not found" |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | +
|
| 68 | + # Clone deployment repository |
| 69 | + git clone "https://x-access-token:${GH_TOKEN}@github.com/fro-bot/systematic.git" deploy-repo |
| 70 | + cd deploy-repo |
| 71 | +
|
| 72 | + # Clean and copy new docs (preserve .git directory) |
| 73 | + find . -mindepth 1 -not -path './.git' -not -path './.git/*' -delete |
| 74 | + cp -r ../docs/dist/* . |
| 75 | +
|
| 76 | + # Commit and push if there are changes |
| 77 | + git add -A |
| 78 | + if ! git diff-index --quiet HEAD --; then |
| 79 | + git commit -m "Deploy docs from marcusrbrown/systematic@${{ github.sha }}" |
| 80 | + git push |
| 81 | + else |
| 82 | + echo "No changes to commit" |
| 83 | + fi |
0 commit comments