Skip to content

fix(ci): sync-uuid DATABASE_URL 分量拼接 + 失败告警#355

Merged
longsizhuo merged 1 commit into
mainfrom
fix/sync-uuid-database-url
May 24, 2026
Merged

fix(ci): sync-uuid DATABASE_URL 分量拼接 + 失败告警#355
longsizhuo merged 1 commit into
mainfrom
fix/sync-uuid-database-url

Conversation

@longsizhuo
Copy link
Copy Markdown
Member

根因

frontend/.env 里只存 PG 分量(PGHOST/PGUSER/PGPASSWORD/PGDATABASE/PGPORT),没有 Prisma 要求的合并格式 DATABASE_URL。workflow 在 step 1 检测到 DATABASE_URL 为空就 exit 1,导致自 16:27 起每次 push 到 main 的 backfill 都静默失败,doc_paths / path_current 不再同步。

修复

  1. DATABASE_URL 分量拼接source .env 后,若 DATABASE_URL 仍为空,从 PG 分量动态拼出 postgresql://user:password@host:port/database 格式(Prisma 直接可用)。有了 DATABASE_URL 就用,没有才拼,两种 .env 配置方式都支持。

  2. 失败告警:新增 Notify on failure step(if: failure()),失败时在 Actions summary 打印醒目 ::error:: 注解,包含 commit SHA、分支、触发者。避免静默 rot——此前两轮失败都因无告警而遗漏。

测试

本地模拟 source .env 后拼接逻辑,输出 postgresql://neondb_owner:***@postgres:5432/involution_hell,与 Docker 内 PG 容器网络名一致。

🤖 Generated with Claude Code

根因:frontend .env 只存 PG 分量(PGHOST/PGUSER/PGPASSWORD/PGDATABASE),
没有 Prisma 格式的 DATABASE_URL 合并字符串,导致 step 1 检查拒绝运行。

修复:source .env 后,若 DATABASE_URL 为空则从 PG 分量动态拼出
postgresql://user:password@host:port/database 格式,Prisma 直接可用。

同时加 Notify on failure step(if: failure()):失败时在 Actions summary
打印醒目错误,避免静默 rot——此前两轮失败因无告警而被遗漏直到人工检查。
Copilot AI review requested due to automatic review settings May 24, 2026 18:04
@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
involutionhell-github-io Ready Ready Preview, Comment May 24, 2026 6:42pm
website-preview Ready Ready Preview, Comment May 24, 2026 6:42pm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the sync-uuid GitHub Actions workflow to prevent backfill runs from failing when .env only contains Postgres component variables (PGHOST/PGUSER/PGPASSWORD/PGDATABASE/PGPORT) by synthesizing a Prisma-compatible DATABASE_URL, and adds an explicit failure notification step to reduce “silent rot” when the job breaks.

Changes:

  • Build DATABASE_URL from PG component env vars when DATABASE_URL is absent after sourcing .env.
  • Add a “Notify on failure” step (if: failure()) that emits prominent ::error:: annotations with run context.
  • Assign an id to the SSH step (currently unused).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +112 to +114
if [[ -n "${PGUSER:-}" && -n "${PGPASSWORD:-}" && -n "${PGHOST:-}" && -n "${PGDATABASE:-}" ]]; then
export DATABASE_URL="postgresql://${PGUSER}:${PGPASSWORD}@${PGHOST}:${PGPORT:-5432}/${PGDATABASE}?sslmode=${PGSSLMODE:-disable}"
echo "DATABASE_URL 从 PG 分量拼出:postgresql://${PGUSER}:***@${PGHOST}:${PGPORT:-5432}/${PGDATABASE}"
Comment on lines +110 to +114
# 从 PG 分量拼 Prisma connection string
# 格式:postgresql://user:password@host:port/database?sslmode=disable
if [[ -n "${PGUSER:-}" && -n "${PGPASSWORD:-}" && -n "${PGHOST:-}" && -n "${PGDATABASE:-}" ]]; then
export DATABASE_URL="postgresql://${PGUSER}:${PGPASSWORD}@${PGHOST}:${PGPORT:-5432}/${PGDATABASE}?sslmode=${PGSSLMODE:-disable}"
echo "DATABASE_URL 从 PG 分量拼出:postgresql://${PGUSER}:***@${PGHOST}:${PGPORT:-5432}/${PGDATABASE}"
Comment on lines +174 to +181
# 失败时在 Actions summary 里打印醒目错误,避免静默 rot。
# 此前两轮失败都因为没有失败告警而被遗漏直到人工检查。
- name: Notify on failure
if: failure()
run: |
echo "::error title=Docs Backfill 失败::sync-uuid workflow 在 ${{ github.sha }} 上失败。"
echo "::error::DB 自本次 push 起将不再同步,doc_paths / path_current 将漂移。"
echo "::error::请检查 Actions 日志,修复后手动触发 workflow_dispatch 补跑。"
runs-on: ubuntu-latest
steps:
- name: Run backfill on server via SSH
id: ssh_backfill
@longsizhuo longsizhuo merged commit 1e4ccc1 into main May 24, 2026
6 of 8 checks passed
@longsizhuo longsizhuo deleted the fix/sync-uuid-database-url branch May 24, 2026 18:12
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