fix(ci): sync-uuid DATABASE_URL 分量拼接 + 失败告警#355
Merged
Conversation
根因: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——此前两轮失败因无告警而被遗漏直到人工检查。
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
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_URLfrom PG component env vars whenDATABASE_URLis absent after sourcing.env. - Add a “Notify on failure” step (
if: failure()) that emits prominent::error::annotations with run context. - Assign an
idto 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
根因
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不再同步。修复
DATABASE_URL 分量拼接:
source .env后,若DATABASE_URL仍为空,从 PG 分量动态拼出postgresql://user:password@host:port/database格式(Prisma 直接可用)。有了DATABASE_URL就用,没有才拼,两种.env配置方式都支持。失败告警:新增
Notify on failurestep(if: failure()),失败时在 Actions summary 打印醒目::error::注解,包含 commit SHA、分支、触发者。避免静默 rot——此前两轮失败都因无告警而遗漏。测试
本地模拟 source .env 后拼接逻辑,输出
postgresql://neondb_owner:***@postgres:5432/involution_hell,与 Docker 内 PG 容器网络名一致。🤖 Generated with Claude Code