Files
Cloud-Blog/.github/workflows/build.yml
2026-01-17 14:01:47 +08:00

88 lines
2.0 KiB
YAML

name: Build and Deploy
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Install Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Check Linting
run: bun run lint
- name: Check Format
run: bun run format
- name: Run Unit Tests
run: bun run test
- name: Playgroud build check
run: bun run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build-output-${{ github.sha }}
path: .output/public
retention-days: 7
- name: Playgroud generate check
run: bun run generate
- name: Upload generate artifact
uses: actions/upload-artifact@v4
with:
name: generate-output-${{ github.sha }}
path: dist
retention-days: 7
deploy:
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download generate artifact
uses: actions/download-artifact@v4
with:
name: generate-output-${{ github.sha }}
path: artifact
- name: List artifact contents
run: |
echo "Contents:" && ls -la artifact || true
- name: Install Bun
uses: oven-sh/setup-bun@v2
- name: Prepare deployment
run: |
bun install -g edgeone vercel wrangler
unzip artifact/generate-output-${{ github.sha }}.zip -d artifact/generate-output-${{ github.sha }}
cd artifact/generate-output-${{ github.sha }}
- name: Deploy to Vercel
run: |
vercel --token ${{ secrets.VERCEL_TOKEN }} --prod