mirror of
https://github.com/Lifeforge-app/lifeforge.git
synced 2026-06-28 14:55:45 +00:00
127 lines
3.4 KiB
YAML
127 lines
3.4 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 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: 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 upgrade && bun install --linker isolated
|
|
|
|
- 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
|
|
});
|
|
}
|