Skip to content

Commit 73cb52e

Browse files
committed
ci(sb2): restore the single Coolify webhook redeploy
Reverts the workflow part of f82a4f9. The step-level env was visible to the step's if after all (the webhook fired on 40de5bc), and development deploys use the same COOLIFY_WEBHOOK, so the per-branch secret only made development skip its redeploy. The STUDIO_IMAGE_TAG pin is dropped too: the CI webhook redeploy already pulls the image it just pushed.
1 parent d9218bc commit 73cb52e

3 files changed

Lines changed: 6 additions & 34 deletions

File tree

‎.github/workflows/build-studio-image.yml‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ env:
2929
jobs:
3030
build-and-push:
3131
runs-on: ubuntu-latest
32-
env:
33-
# Job-level, not step-level: a step's own `env` is not visible to its `if`.
34-
# Each branch redeploys its own Coolify application, so a development
35-
# push can never redeploy production.
36-
COOLIFY_WEBHOOK: ${{ github.ref_name == 'master' && secrets.COOLIFY_WEBHOOK || github.ref_name == 'development' && secrets.COOLIFY_WEBHOOK_DEVELOPMENT || '' }}
3732
steps:
3833
- uses: actions/checkout@v4
3934

@@ -60,33 +55,12 @@ jobs:
6055
cache-from: type=gha
6156
cache-to: type=gha,mode=max
6257

63-
# A missing secret would otherwise skip the redeploy without a trace.
64-
- name: Warn when no Coolify webhook is set for this branch
65-
if: success() && env.COOLIFY_WEBHOOK == '' && (github.ref_name == 'master' || github.ref_name == 'development')
66-
run: |
67-
echo "::warning title=Coolify redeploy skipped::Repository secret ${{ github.ref_name == 'master' && 'COOLIFY_WEBHOOK' || 'COOLIFY_WEBHOOK_DEVELOPMENT' }} is not set, so Coolify was not redeployed with this image."
68-
69-
# Pin the Coolify app to the image this run just built, then redeploy.
70-
# A moving tag (:latest / :development) lets a redeploy pull a Studio
71-
# built from a different commit than the compose file and agent it runs
72-
# beside. Requires a STUDIO_IMAGE_TAG variable to exist on the Coolify
73-
# application (the API only updates existing variables).
7458
- name: Trigger Coolify redeploy
7559
if: success() && env.COOLIFY_WEBHOOK != ''
7660
env:
61+
COOLIFY_WEBHOOK: ${{ secrets.COOLIFY_WEBHOOK }}
7762
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
7863
run: |
79-
# The deploy webhook is <coolify>/api/v1/deploy?uuid=<app-uuid>[&...].
80-
COOLIFY_API="${COOLIFY_WEBHOOK%%/api/v1/*}/api/v1"
81-
APP_UUID=$(printf '%s' "$COOLIFY_WEBHOOK" | sed -n 's/.*[?&]uuid=\([^&]*\).*/\1/p')
82-
if [ -z "$APP_UUID" ]; then
83-
echo "COOLIFY_WEBHOOK has no uuid= parameter: expected <coolify>/api/v1/deploy?uuid=<app-uuid>" >&2
84-
exit 1
85-
fi
86-
curl --fail-with-body -X PATCH "$COOLIFY_API/applications/$APP_UUID/envs" \
87-
-H "Authorization: Bearer $COOLIFY_TOKEN" \
88-
-H "Content-Type: application/json" \
89-
-d "{\"key\":\"STUDIO_IMAGE_TAG\",\"value\":\"${{ github.sha }}\"}"
9064
curl --fail-with-body -X GET "$COOLIFY_WEBHOOK" \
9165
-H "Authorization: Bearer $COOLIFY_TOKEN"
9266

‎docker/superbase2/.env.coolify‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,10 @@ SITE_URL=https://app.yourdomain.com
8585

8686
# ── Optional overrides (safe defaults exist — only set if needed) ────────────
8787

88-
# Which pre-built Studio image to run. Leave unset to follow the moving tag
89-
# (master publishes :latest). When the GitHub workflow redeploys this app
90-
# (COOLIFY_WEBHOOK secret), it sets this to the commit SHA it just built so
91-
# Studio always matches the deployed compose file — create the variable here
92-
# (any value) for that to work, since Coolify's API only updates existing ones.
93-
# STUDIO_IMAGE_TAG=latest
88+
# Which pre-built Studio image to run. master publishes :latest, the
89+
# development branch publishes :development. Leave unset for latest; set it
90+
# to development on a test deployment so it tracks that branch instead.
91+
# STUDIO_IMAGE_TAG=development
9492

9593
# App-layer basic-auth (defense-in-depth, on top of Kong). Enabled by default
9694
# in the compose. Set to false only if you must disable the in-app credential

‎docker/superbase2/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Coolify expects a single compose file — it does not support the multi-file `-f
165165

166166
10. Deploy — Coolify pulls the pre-built Studio image from ghcr.io (fast, no build step).
167167

168-
11. (Optional) **Redeploy from CI.** `.github/workflows/build-studio-image.yml` builds the Studio image on pushes to `master` and `development` and can redeploy Coolify afterwards. Add GitHub secrets `COOLIFY_WEBHOOK` (master's app) and/or `COOLIFY_WEBHOOK_DEVELOPMENT` (a separate test app), plus `COOLIFY_TOKEN` (a Coolify API token with deploy and write access). Also create a `STUDIO_IMAGE_TAG` variable on each Coolify app: the workflow sets it to the commit SHA it just built before redeploying, so Studio always matches the compose file and agent deployed next to it.
168+
11. (Optional) **Redeploy from CI.** `.github/workflows/build-studio-image.yml` builds the Studio image on pushes to `master` (`:latest`) and `development` (`:development`) that touch Studio, then calls the Coolify deploy webhook. Add GitHub secrets `COOLIFY_WEBHOOK` (the app's deploy webhook URL) and `COOLIFY_TOKEN` (a Coolify API token with deploy access). With auto-deploy on, a push deploys twice: Coolify deploys the compose and agent right away with the previous Studio image, then the webhook redeploys once CI has pushed the new one.
169169

170170
### What happens on first boot
171171

0 commit comments

Comments
 (0)