|
| 1 | +name: Documentation Build Check |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: docs-build-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + build-docs: |
| 20 | + name: Verify Documentation Build |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout ai-cookbook repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + path: ai-cookbook |
| 28 | + |
| 29 | + - name: Checkout documentation repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + repository: temporalio/documentation |
| 33 | + path: documentation |
| 34 | + |
| 35 | + - name: Setup Node.js |
| 36 | + uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: "20" |
| 39 | + |
| 40 | + - name: Detect package manager and install dependencies |
| 41 | + working-directory: documentation |
| 42 | + run: | |
| 43 | + if [ -f "yarn.lock" ]; then |
| 44 | + echo "Using yarn" |
| 45 | + corepack enable |
| 46 | + yarn install --frozen-lockfile |
| 47 | + elif [ -f "pnpm-lock.yaml" ]; then |
| 48 | + echo "Using pnpm" |
| 49 | + corepack enable |
| 50 | + pnpm install --frozen-lockfile |
| 51 | + elif [ -f "package-lock.json" ]; then |
| 52 | + echo "Using npm" |
| 53 | + npm ci |
| 54 | + else |
| 55 | + echo "No lockfile found, using npm install" |
| 56 | + npm install |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Configure ai-cookbook to use local checkout |
| 60 | + working-directory: documentation |
| 61 | + run: | |
| 62 | + # Look for sample fetch configurations and update them to use local ai-cookbook |
| 63 | + # This ensures the doc build uses the PR's ai-cookbook content, not the remote main branch |
| 64 | + |
| 65 | + # Check for common config file patterns and update ai-cookbook references |
| 66 | + for config_file in samples-fetch.json assembly/assembly.json assembly.json .snipsync.json snipsync.yaml; do |
| 67 | + if [ -f "$config_file" ]; then |
| 68 | + echo "Found config file: $config_file" |
| 69 | + # Update GitHub URLs to local path |
| 70 | + sed -i 's|https://github.com/temporalio/ai-cookbook\.git|../ai-cookbook|g' "$config_file" || true |
| 71 | + sed -i 's|https://github.com/temporalio/ai-cookbook|../ai-cookbook|g' "$config_file" || true |
| 72 | + sed -i 's|git@github.com:temporalio/ai-cookbook\.git|../ai-cookbook|g' "$config_file" || true |
| 73 | + sed -i 's|temporalio/ai-cookbook@main|../ai-cookbook|g' "$config_file" || true |
| 74 | + cat "$config_file" |
| 75 | + fi |
| 76 | + done |
| 77 | + |
| 78 | + # If there's a script that clones/fetches ai-cookbook, we may need to skip it |
| 79 | + # since we already have the local checkout |
| 80 | +
|
| 81 | + - name: Fetch samples and external content |
| 82 | + working-directory: documentation |
| 83 | + run: | |
| 84 | + # Try common sample fetching approaches |
| 85 | + if [ -f "scripts/fetch-samples.sh" ]; then |
| 86 | + echo "Running fetch-samples.sh" |
| 87 | + chmod +x scripts/fetch-samples.sh |
| 88 | + ./scripts/fetch-samples.sh || true |
| 89 | + fi |
| 90 | + |
| 91 | + # Check for npm/yarn scripts that fetch samples |
| 92 | + if grep -q '"samples:fetch"' package.json 2>/dev/null; then |
| 93 | + echo "Running samples:fetch script" |
| 94 | + if [ -f "yarn.lock" ]; then |
| 95 | + yarn samples:fetch || true |
| 96 | + else |
| 97 | + npm run samples:fetch || true |
| 98 | + fi |
| 99 | + fi |
| 100 | + |
| 101 | + if grep -q '"fetch-samples"' package.json 2>/dev/null; then |
| 102 | + echo "Running fetch-samples script" |
| 103 | + if [ -f "yarn.lock" ]; then |
| 104 | + yarn fetch-samples || true |
| 105 | + else |
| 106 | + npm run fetch-samples || true |
| 107 | + fi |
| 108 | + fi |
| 109 | +
|
| 110 | + - name: Build documentation site |
| 111 | + working-directory: documentation |
| 112 | + run: | |
| 113 | + if [ -f "yarn.lock" ]; then |
| 114 | + yarn build |
| 115 | + elif [ -f "pnpm-lock.yaml" ]; then |
| 116 | + pnpm build |
| 117 | + else |
| 118 | + npm run build |
| 119 | + fi |
| 120 | +
|
| 121 | + - name: Report success |
| 122 | + run: | |
| 123 | + echo "✅ Documentation site builds successfully with ai-cookbook changes" |
| 124 | + echo "" |
| 125 | + echo "This validates that changes in this PR/commit do not break the Temporal documentation site." |
0 commit comments