Files
lifeforge/.github/workflows/build.yml
Melvin Chia e8690ec913 style: prettier reformatting of the entire codebase
Former-commit-id: 6ad2fac2e9cab83dd484e90e80732067d22616e8 [formerly 0834b7e2aaeb6a04e31f5f04cf88f01b2c256986] [formerly a4dcf0af4dfe6fcf744184676baa2d4caeb40fc7 [formerly 9632ffb6671d8f30ca33c51bda106c299a4c07da]]
Former-commit-id: 23ac95ccea08e36479fe17ac5ae4c2bdc4d77119 [formerly 450788517ac9fabdc16607b8f41785bb5c55917e]
Former-commit-id: 256d0df6be62899478c8a3a5258f296649f4672d
2025-10-05 12:39:16 +08:00

142 lines
3.8 KiB
YAML

name: Build
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
jobs:
build-backend:
name: Build Backend
runs-on: ubuntu-latest
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 install --frozen-lockfile
- 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: ubuntu-latest
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 install --frozen-lockfile
- name: Type check shared package
run: bun run forge types shared
- name: Build shared package
run: bun run forge build shared
- name: Type check UI package
run: bun run forge types ui
- name: Build UI package
run: bun run forge build ui
- name: Type check client
run: bun run forge types client
- name: Build client
run: bun run forge build client
build-summary:
name: Build Summary
runs-on: ubuntu-latest
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
});
}