Skip to content

feat(reusable-build): guard nhánh production, fail nếu bundle chứa host backend staging trước khi push - #7

Merged
meocong merged 2 commits into
mainfrom
feat/reusable-build-prod-staging-guard
Nov 17, 2026
Merged

meocong merged 2 commits into
mainfrom
feat/reusable-build-prod-staging-guard

Conversation

@meocong

@meocong meocong commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@meocong

meocong commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Blocked, not merged: the guard would fail current production builds of Techainer/prj-ths-smart-class (it calls reusable-build on branch production via gitops-deploy.yml). Its source ships src/lib/posthog.ts:30, a host->PostHog-key map with the key "api-smart-class-staging.truonghocsoquocgia.vn". That string matches FAIL_RE ((api|go|hasura|auth)(-[a-z0-9]+)*-staging.…truonghocsoquocgia) and is compiled into the production bundle, so the build would exit 1 before push. A scan of the other callers' production and develop sources (school-frontend, shadcn-frontend, shadcn-admin, admin-lms, attendance-hub, live-class, frontend-game, exam-module, slide-frontend, agent-platform, backend-smart-class) found no FAIL_RE hits in source; baked .env values can't be checked from source. Suggested fix: make the guard ignore host strings that are keys of a host->environment table (or match only the actual configured API base URL), not any occurrence. Second issue: 'grep … | tee | grep -q .' under pipefail can return 141 (SIGPIPE) and silently skip the failure; capture hits into a variable and test [ -n "$HITS" ] instead.

…ging, sửa bỏ sót do pipefail

Host trần trong bảng ánh xạ (posthog.ts của smart-class) làm fail nhầm build production.
tee | grep -q dưới pipefail có thể SIGPIPE và bỏ qua hit thật; ghi file rồi test -s.
Kiểm trên image thật: prod smart-class/admin/lms-admin OK; image staging lms-admin fail đúng.
@meocong

meocong commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Đã sửa 2 điểm chặn: FAIL_RE cần scheme (https?|wss?)://; bỏ tee | grep -q, ghi file + test -s. Kiểm guard trên image thật: smart-class production-19a03b0, admin production-708a6e0, lms-admin production-b0ce6db -> OK; lms-admin production-staging-b0ce6db -> fail (21 hit api-staging), đúng kỳ vọng. actionlint sạch.

@meocong
meocong merged commit 505bbda into main Nov 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants