ci: 修复 Gitea Actions 数据库连接(用服务名 postgres) #2
Reference in New Issue
Block a user
Delete Branch "devin/1781859199-ci-fix-postgres-host"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
仓库 CI(Actions run #3)一直显示失败:三个 job 均 0s 被取消,根因是 该仓库没有注册任何 Actions Runner(设置→运行器 总计 0),任务排队后被取消。
注册 Runner 后重跑,又暴露出工作流本身的可移植性问题:
原因
Gitea Actions 的 job 运行在容器内,service 容器需通过服务名(
postgres)访问;localhost:5432是 GitHub Actions(job 直接跑在宿主机上)的约定,在 Gitea 容器化运行下连不通。此外ports: 5432:5432的宿主机端口映射既无必要,又会与宿主机已占用端口冲突(port already allocated)。改动
go和migrations两个 job:localhost→postgres(service 名)ports: - "5432:5432"映射pythonjob 不连库(DB 测试在无库时自动跳过),无需改动。验证
本地已通过全部 CI 步骤:Go gofmt/vet/build/test、Python ruff+pytest(33 passed)、migrate up/down 可逆。本 PR 会在 Gitea Runner 上触发 CI 以验证修复。