-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (114 loc) · 3.77 KB
/
Copy pathbuild-images.yml
File metadata and controls
127 lines (114 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Build and publish images
on:
push:
branches: [main]
paths:
- ".github/workflows/**"
- "editor-backend/**"
- "Dockerfile"
- "package.json"
- "bun.lock"
- "src/**"
- "public/**"
- "next.config.ts"
- ".gitattributes"
- "scripts/docker-entrypoint.sh"
- "drizzle/**"
workflow_dispatch:
env:
REGISTRY: ghcr.io
EDITOR_BACKEND_IMAGE: ghcr.io/${{ github.repository_owner }}/breadboard-editor-backend
NEXTJS_IMAGE: ghcr.io/${{ github.repository_owner }}/breadboard
jobs:
# ── Quick gates before heavy builds ──────────────────────────────
gate:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.6"
- run: bun install --frozen-lockfile
- run: bun run lint
- run: bunx tsc --noEmit
# ── Editor backend (heavy: ESP-IDF + QEMU + arduino-cli) ────────
editor-backend:
runs-on: ubuntu-latest
needs: gate
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push editor backend
uses: docker/build-push-action@v6
with:
context: ./editor-backend
file: ./editor-backend/Dockerfile
push: true
tags: |
${{ env.EDITOR_BACKEND_IMAGE }}:latest
${{ env.EDITOR_BACKEND_IMAGE }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ── Next.js app ─────────────────────────────────────────────────
nextjs:
runs-on: ubuntu-latest
needs: gate
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Next.js
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.NEXTJS_IMAGE }}:latest
${{ env.NEXTJS_IMAGE }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ── Deploy (triggers Orchard webhooks for both services) ────────
deploy:
runs-on: ubuntu-22.04
needs: [editor-backend, nextjs]
environment: production
env:
ORCHARD_WEBHOOK_NEXTJS: ${{ secrets.ORCHARD_WEBHOOK_NEXTJS }}
ORCHARD_WEBHOOK_BACKEND: ${{ secrets.ORCHARD_WEBHOOK_BACKEND }}
steps:
- name: Trigger Next.js Orchard deploy
if: env.ORCHARD_WEBHOOK_NEXTJS != ''
run: |
curl -sS -X POST "$ORCHARD_WEBHOOK_NEXTJS" \
-H "Content-Type: application/json" \
-d '{"tag":"${{ github.sha }}"}'
echo "Next.js webhook dispatched"
- name: Trigger editor-backend Orchard deploy
if: env.ORCHARD_WEBHOOK_BACKEND != ''
run: |
curl -sS -X POST "$ORCHARD_WEBHOOK_BACKEND" \
-H "Content-Type: application/json" \
-d '{"tag":"${{ github.sha }}"}'
echo "Editor backend webhook dispatched"