- Deploy job runs after tests pass, only on push to main - Uses Dokploy compose.deploy API with secrets for URL, token, compose ID - PRs only run tests (no deploy)
48 lines
1.0 KiB
YAML
48 lines
1.0 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
|
|
steps:
|
|
- name: Checkout
|
|
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: Run tests
|
|
run: bun test --bail
|
|
|
|
- name: Type check
|
|
run: bun x tsc --noEmit
|
|
|
|
deploy:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- name: Deploy to Dokploy
|
|
run: |
|
|
curl -fsSL -X POST \
|
|
"${{ secrets.DOKPLOY_URL }}/api/compose.deploy" \
|
|
-H "Content-Type: application/json" \
|
|
-H "x-api-key: ${{ secrets.DOKPLOY_API_TOKEN }}" \
|
|
-d '{"composeId": "${{ secrets.DOKPLOY_COMPOSE_ID }}"}'
|
|
echo "✅ Deploy triggered on Dokploy"
|