Files
jonbio/.gitea/workflows/build.yml
trex Bot d2b77e488f ci: deploy via Komodo stack webhook, tag images with commit sha
The old deploy step POSTed to http://10.5.0.11:7777/v1/update, which no
longer exists (connection refused), so every push built and pushed a new
image but never reached the site.

Replace it with the Komodo stack webhook for `jonbio`
(/listener/github/stack/jonbio/deploy), HMAC-signed with a per-stack
secret. The stack has auto_pull + webhook_force_deploy enabled, so the
webhook pulls :latest and recreates the container.

Also tag each build with the commit sha alongside :latest so a bad
deploy can be rolled back to a known image.
2026-11-18 15:25:58 -06:00

101 lines
3.4 KiB
YAML

name: Build and Deploy docker container
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
- name: Install Yarn
run: npm install -g yarn
- name: Set Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Restore cache
uses: actions/cache@v4
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
${{ github.workspace }}/.next/
node_modules/
${{ github.workspace }}/out/
key: '${{ runner.os }}-yarn-${{ hashFiles(''**/yarn.lock'') }}'
restore-keys: |
${{ runner.os }}-yarn-
- name: Update node modules
run: yarn install --immutable
- name: Lint
run: yarn lint
- name: Build app and export to ./out
run: EXPORT=1 UNOPTIMIZED=1 NEXT_UMAMI_ID='${{ secrets.JONBIO_UMAMI_ID }}' yarn build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: git.jonb.io
username: '${{ gitea.actor }}'
password: '${{ secrets.JONBIO_CI }}'
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
git.jonb.io/jblu/jonbio:latest
git.jonb.io/jblu/jonbio:${{ gitea.sha }}
cache-from: 'type=registry,ref=git.jonb.io/jblu/jonbio:buildcache'
cache-to: >-
type=registry,image-manifest=true,oci-mediatypes=true,ref=git.jonb.io/jblu/jonbio:buildcache,mode=max
# Triggers the Komodo stack webhook for `jonbio`, which pulls :latest and
# recreates the container. Replaces the old http://10.5.0.11:7777/v1/update
# hook, which no longer exists.
- name: Deploy via Komodo
env:
KOMODO_WEBHOOK_SECRET: ${{ secrets.KOMODO_JONBIO_WEBHOOK_SECRET }}
COMMIT_SHA: ${{ gitea.sha }}
run: |
if [ -z "$KOMODO_WEBHOOK_SECRET" ]; then
echo "::error::KOMODO_JONBIO_WEBHOOK_SECRET is not set on this repo"
exit 1
fi
cat > /tmp/komodo-deploy.mjs <<'EOF'
import crypto from 'node:crypto'
const payload = JSON.stringify({
ref: 'refs/heads/main',
after: process.env.COMMIT_SHA,
repository: { full_name: 'jblu/jonbio', default_branch: 'main' },
})
const signature =
'sha256=' +
crypto.createHmac('sha256', process.env.KOMODO_WEBHOOK_SECRET).update(payload).digest('hex')
const res = await fetch('http://10.5.0.3:9120/listener/github/stack/jonbio/deploy', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-GitHub-Event': 'push',
'X-Hub-Signature-256': signature,
},
body: payload,
})
const body = await res.text()
console.log(`Komodo deploy -> ${res.status} ${body}`)
if (!res.ok) process.exit(1)
EOF
node /tmp/komodo-deploy.mjs