|
1 | 1 | name: Publish Docs
|
2 | 2 |
|
| 3 | +concurrency: |
| 4 | + # No suffix specified - in reusable workflows we need a statically-defined suffix |
| 5 | + # to prevent workflow_call workflows from triggering a concurrency deadlock |
| 6 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 7 | + cancel-in-progress: true |
| 8 | + |
3 | 9 | on:
|
| 10 | + pull_request: |
4 | 11 | push:
|
5 | 12 | branches:
|
6 | 13 | - canary
|
7 | 14 |
|
8 | 15 | jobs:
|
9 |
| - run: |
| 16 | + docs: |
10 | 17 | runs-on: ubuntu-latest
|
| 18 | + permissions: write-all |
11 | 19 | steps:
|
12 | 20 | - name: Checkout repository
|
13 | 21 | uses: actions/checkout@v4
|
14 | 22 |
|
| 23 | + - name: Setup Node.js and pnpm |
| 24 | + uses: ./.github/actions/setup-node |
| 25 | + with: |
| 26 | + install-dependencies: false |
| 27 | + |
15 | 28 | - name: Install Fern
|
16 | 29 | run: npm install -g fern-api
|
17 | 30 |
|
18 |
| - - name: Publish Docs |
| 31 | + - name: Install dependencies and build custom.js |
| 32 | + working-directory: ./typescript/apps/sage-client |
| 33 | + run: pnpm install && pnpm run build |
| 34 | + |
| 35 | + - name: Generate preview URL |
| 36 | + id: generate-docs |
19 | 37 | env:
|
20 | 38 | FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
|
21 |
| - run: fern generate --docs |
| 39 | + run: | |
| 40 | + fern check --strict-broken-links |
| 41 | + if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/canary" ]; then |
| 42 | + OUTPUT=$(fern generate --docs 2>&1) || true |
| 43 | + else |
| 44 | + OUTPUT=$(fern generate --docs --preview 2>&1) || true |
| 45 | + fi |
| 46 | + echo "$OUTPUT" |
| 47 | + URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()') |
| 48 | + echo "🌿 Preview your docs: $URL" | tee preview_url.txt |
| 49 | +
|
| 50 | + - name: Comment URL in PR |
| 51 | + if: github.event_name == 'pull_request' |
| 52 | + uses: thollander/[email protected] |
| 53 | + with: |
| 54 | + file-path: preview_url.txt |
| 55 | + |
| 56 | + backend: |
| 57 | + runs-on: ubuntu-latest |
| 58 | + permissions: write-all |
| 59 | + defaults: |
| 60 | + run: |
| 61 | + working-directory: ../sage-backend |
| 62 | + steps: |
| 63 | + - name: Checkout repository |
| 64 | + uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Setup Node.js and pnpm |
| 67 | + uses: ./.github/actions/setup-node |
| 68 | + with: |
| 69 | + install-dependencies: false |
| 70 | + |
| 71 | + - name: Install Fern |
| 72 | + working-directory: . |
| 73 | + run: npm install -g fern-api |
| 74 | + |
| 75 | + - name: Pull sage-backend out of monorepo |
| 76 | + working-directory: ./typescript |
| 77 | + run: pnpm --filter=sage-backend deploy ../sage-backend |
| 78 | + |
| 79 | + - name: Install dependencies and build |
| 80 | + run: pnpm install && pnpm baml-cli generate |
| 81 | + |
| 82 | + - name: Build Vercel project |
| 83 | + env: |
| 84 | + PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} |
| 85 | + run: | |
| 86 | + pnpm vercel pull --yes --token=${{ secrets.VERCEL_TOKEN_SAM }} |
| 87 | + pnpm vercel build --token=${{ secrets.VERCEL_TOKEN_SAM }} |
| 88 | +
|
| 89 | + - name: Deploy preview backend |
| 90 | + env: |
| 91 | + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} |
| 92 | + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_SAGE_BACKEND }} |
| 93 | + run: | |
| 94 | + ( |
| 95 | + if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/canary" ]; then |
| 96 | + pnpm vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN_SAM }} |
| 97 | + else |
| 98 | + pnpm vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN_SAM }} |
| 99 | + fi |
| 100 | + ) | tee preview_url.txt |
| 101 | +
|
| 102 | + - name: Comment URL in PR |
| 103 | + if: github.event_name == 'pull_request' |
| 104 | + uses: thollander/[email protected] |
| 105 | + with: |
| 106 | + file-path: ../sage-backend/preview_url.txt |
0 commit comments