Skip to content

Commit ae27d10

Browse files
committed
ci: simplify review apps to match historical 2020 pattern
The previous commit reinvented review apps with a bunch of new machinery (PREVIEW_BASE_DOMAIN, stop_review job, auto_stop_in, on_stop wiring). The existing infrastructure already has the `review` namespace, the ingress, and the Cloudflare wildcard for *.pgai.green — review apps just need to deploy `docs-<slug>` into the `review` namespace and the rest is handled outside this repo. This commit replaces the over-engineered version with the same minimal shape that lived here before commit 43d434c (Oct 2020, "fix: remove review CI"), adapted to the current TAG_VERSION/TAG_LATEST naming and with the correct external URL (https://docs-<slug>.pgai.green). Also drops the per-branch overwrite of the staging deployment by scoping `build_and_push_staging` / `deploy_staging` to the `staging` branch only — that bug is the actual reason previews stopped working: every dev push was clobbering the shared staging Deployment instead of getting an isolated review env. https://claude.ai/code/session_015AC273dXNKXd8gG5QpC152
1 parent 1ca4bf0 commit ae27d10

3 files changed

Lines changed: 23 additions & 50 deletions

File tree

.gitlab-ci.yml

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ variables:
2121
TAG_VERSION: "${REGISTRY}:${NAMESPACE}-${CI_PIPELINE_IID}"
2222
TAG_LATEST: "${REGISTRY}:${NAMESPACE}-latest"
2323
DOCS_NAME: "docs"
24-
# Base domain for per-branch preview environments.
25-
# Override via project CI/CD variable if your infrastructure uses a different host.
26-
PREVIEW_BASE_DOMAIN: "preview-docs.postgres.ai"
2724

2825
# Validate RSS/Atom feeds before building and deploying
2926
validate_feeds:
@@ -121,21 +118,21 @@ validate_feeds:
121118
NAMESPACE: staging
122119

123120
# Per-branch preview environment.
124-
# Each non-master branch gets its own isolated deployment in the `review`
125-
# namespace, named after the branch slug, exposed at
126-
# https://${CI_COMMIT_REF_SLUG}.${PREVIEW_BASE_DOMAIN}.
127-
# The environment is automatically torn down when the branch is deleted
128-
# (via `stop_review`, wired up through `environment.on_stop`).
121+
# Restores the review-apps pattern that existed before commit 43d434c
122+
# ("fix: remove review CI", Oct 2020). The cluster's existing ingress +
123+
# Cloudflare wildcard *.pgai.green route to the per-branch Service named
124+
# `docs-<slug>` in the `review` namespace — no extra ingress object needed.
129125
.environment_template: &env_review
130126
environment:
131-
name: review/$CI_COMMIT_REF_SLUG
132-
url: https://$CI_COMMIT_REF_SLUG.$PREVIEW_BASE_DOMAIN
133-
on_stop: stop_review
134-
auto_stop_in: 1 week
127+
name: review/$CI_COMMIT_REF_NAME
128+
url: https://docs-${CI_COMMIT_REF_SLUG}.pgai.green
135129
variables:
136130
ENV: review
137131
NAMESPACE: review
138-
DOCS_NAME: "docs-$CI_COMMIT_REF_SLUG"
132+
# Branch-scoped tags so concurrent previews don't fight over the same one.
133+
TAG_VERSION: "${REGISTRY}:review-${CI_COMMIT_REF_SLUG}-${CI_PIPELINE_IID}"
134+
TAG_LATEST: "${REGISTRY}:review-${CI_COMMIT_REF_SLUG}-latest"
135+
DOCS_NAME: "docs-${CI_COMMIT_REF_SLUG}"
139136

140137
# Stages with branch policies.
141138
build_and_push_production:
@@ -144,16 +141,14 @@ build_and_push_production:
144141
only:
145142
- master
146143

147-
# Static staging environment (v2.postgres.ai). Only the `staging` branch
148-
# deploys here; other development branches get their own preview env below.
144+
# Static staging env (v2.postgres.ai). Only the `staging` branch deploys here;
145+
# other dev branches get their own preview env below so they don't trample it.
149146
build_and_push_staging:
150147
<<: *build_and_push_definition
151148
<<: *env_staging
152149
only:
153150
- staging
154151

155-
# Per-branch preview environments — automatic build on every push to a
156-
# development branch.
157152
build_and_push_review:
158153
<<: *build_and_push_definition
159154
<<: *env_review
@@ -180,27 +175,3 @@ deploy_review:
180175
except:
181176
- master
182177
- staging
183-
184-
# Triggered automatically when the branch is deleted (or manually from the
185-
# Environments page). Tears down the per-branch Deployment and Service so
186-
# stale previews do not pile up.
187-
stop_review:
188-
stage: deploy
189-
image: dtzar/helm-kubectl:2.14.1
190-
variables:
191-
ENV: review
192-
NAMESPACE: review
193-
DOCS_NAME: "docs-$CI_COMMIT_REF_SLUG"
194-
GIT_STRATEGY: none
195-
environment:
196-
name: review/$CI_COMMIT_REF_SLUG
197-
action: stop
198-
when: manual
199-
script:
200-
- kubectl config get-contexts
201-
- kubectl config use-context postgres-ai/docs:k8s-cluster-docs
202-
- kubectl delete deployment "$DOCS_NAME" -n "$NAMESPACE" --ignore-not-found
203-
- kubectl delete service "$DOCS_NAME" -n "$NAMESPACE" --ignore-not-found
204-
except:
205-
- master
206-
- staging

CLAUDE.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Practical implications when using Claude Code here:
3232
GitLab (a corresponding MR is opened on the GitLab side).
3333
- Do **not** push to `master` from any branch — `master` only updates
3434
via the GitLab → GitHub mirror after a GitLab MR is merged.
35-
- Preview environments (`https://<branch-slug>.preview-docs.postgres.ai`)
36-
are provisioned by GitLab CI on every push to a non-`master` branch.
37-
See `.gitlab-ci.yml` (`build_and_push_review` / `deploy_review` /
38-
`stop_review`).
35+
- Preview environments (`https://docs-<branch-slug>.pgai.green`) are
36+
provisioned by GitLab CI on every push to a non-`master` /
37+
non-`staging` branch. See `build_and_push_review` and `deploy_review`
38+
in `.gitlab-ci.yml`. The cluster ingress + Cloudflare wildcard for
39+
`*.pgai.green` already route to the per-branch Service.

deploy/configs/review.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
export REPLICAS=1
22

33
# Per-branch preview environment.
4-
# URL is derived from the GitLab branch slug + PREVIEW_BASE_DOMAIN
5-
# (see `.environment_template: &env_review` in .gitlab-ci.yml).
6-
export URL="https://${CI_COMMIT_REF_SLUG}.${PREVIEW_BASE_DOMAIN}"
4+
# DOCS_NAME / CI_COMMIT_REF_SLUG come from .gitlab-ci.yml's &env_review.
5+
# The cluster's existing Cloudflare + ingress route docs-<slug>.pgai.green
6+
# to the Service named ${DOCS_NAME} in the `review` namespace.
7+
export URL="https://${DOCS_NAME}.pgai.green"
78
export BASE_URL="/"
89

9-
# Previews share the staging API / auth / bot backends — there is no separate
10-
# per-branch backend, only the docs frontend is built per branch.
10+
# Previews share the staging API / auth / bot backends — only the docs
11+
# frontend is built per branch.
1112
export SIGN_IN_URL="https://console-v2.postgres.ai/signin"
1213
export BOT_WS_URL="wss://v2.postgres.ai/ai-bot-ws/"
1314
export API_URL_PREFIX="https://v2.postgres.ai/api/general"

0 commit comments

Comments
 (0)