Skip to content

Push auto screenshots to the GitHub README on submit #221

Push auto screenshots to the GitHub README on submit

Push auto screenshots to the GitHub README on submit #221

Workflow file for this run

name: Build and publish images
on:
push:
branches: [main]
paths:
- "**"
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:
changes:
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: read
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'editor-backend/**'
frontend:
- '**'
- '!editor-backend/**'
# ── Editor backend (heavy: ESP-IDF + QEMU + arduino-cli) ────────
editor-backend:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.backend == 'true'
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: changes
if: needs.changes.outputs.frontend == 'true'
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 }}
build-args: |
NEXT_DEPLOYMENT_ID=${{ github.sha }}
secrets: |
next_server_actions_key=${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ── Deploy (triggers Orchard webhooks for both services) ────────
deploy:
runs-on: ubuntu-22.04
needs: [changes, editor-backend, nextjs]
if: always() && (needs.editor-backend.result == 'success' || needs.nextjs.result == 'success')
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: needs.nextjs.result == 'success' && 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: needs.editor-backend.result == 'success' && 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"