name: Build on: pull_request: types: [opened, synchronize, reopened] permissions: contents: read pull-requests: write jobs: build-backend: name: Build Backend runs-on: blacksmith-4vcpu-ubuntu-2404 steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: latest - name: Install dependencies run: bun upgrade && bun install --linker isolated - name: Type check server run: bun run forge types server - name: Build server run: bun run forge build server build-frontend: name: Build Frontend runs-on: blacksmith-4vcpu-ubuntu-2404 steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: latest - name: Install dependencies run: bun upgrade && bun install --linker isolated - name: Build client run: bun run forge build client build-summary: name: Build Summary runs-on: blacksmith-4vcpu-ubuntu-2404 needs: [build-backend, build-frontend] if: always() && github.event_name == 'pull_request' steps: - name: Comment PR uses: actions/github-script@v7 with: script: | const { owner, repo, number } = context.issue; const runId = context.runId; const backendResult = '${{ needs.build-backend.result }}'; const frontendResult = '${{ needs.build-frontend.result }}'; let summary = '## šŸ”Ø Build Results\n\n'; let allSuccess = true; // Backend status if (backendResult === 'success') { summary += 'āœ… **Backend Build**: Passed\n'; } else { summary += `āŒ **Backend Build**: Failed (${backendResult})\n`; allSuccess = false; } // Frontend status if (frontendResult === 'success') { summary += 'āœ… **Frontend Build**: Passed\n'; } else { summary += `āŒ **Frontend Build**: Failed (${frontendResult})\n`; allSuccess = false; } summary += '\n'; if (allSuccess) { summary += 'šŸŽ‰ All builds completed successfully!'; } else { summary += 'āš ļø One or more builds failed. Please check the logs for details.'; } summary += `\n\nšŸ”— [View full workflow run](https://github.com/${owner}/${repo}/actions/runs/${runId})`; // Find existing comment to update const comments = await github.rest.issues.listComments({ owner, repo, issue_number: number, }); const botComment = comments.data.find( comment => comment.user.type === 'Bot' && comment.body.includes('## šŸ”Ø Build Results') ); if (botComment) { // Update existing comment await github.rest.issues.updateComment({ owner, repo, comment_id: botComment.id, body: summary }); } else { // Create new comment await github.rest.issues.createComment({ owner, repo, issue_number: number, body: summary }); }