diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 7fa569a..237bcfc 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -52,14 +52,49 @@ jobs: with: context: . push: true - tags: 'git.jonb.io/jblu/jonbio:latest' + 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 - - name: Deploy app - uses: fjogeleit/http-request-action@v1 - with: - url: 'http://10.5.0.11:7777/v1/update' - method: GET - bearerToken: '${{ secrets.DEPLOYTOKEN }}' - timeout: 60000 \ No newline at end of file + # 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