现在我正在使用 GitHub Actions 来构建我的项目。在我的本地计算机上,我定义本地主机地址映射如下/etc/hosts:
11.19.178.213 postgres.dolphin.com
Run Code Online (Sandbox Code Playgroud)
在我的数据库配置中,如下所示:
spring.datasource.druid.post.master.jdbc-url = jdbc:postgresql://postgres.dolphin.com:5432/dolphin
Run Code Online (Sandbox Code Playgroud)
在我的生产服务器上,我可以编辑映射来定位数据库的不同 IP 地址。但现在我正在 GitHub Actions 中运行单元测试。如何编辑主机映射以使数据库映射到 GitHub Actions 的容器?我在 GitHub Actions 中定义了容器,如下所示:
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13.2
env:
POSTGRES_PASSWORD: postgrespassword
POSTGRES_DB: dolphin
POSTGRES_USER: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
Run Code Online (Sandbox Code Playgroud)
我应该如何处理主机映射?我已经搜索过文档,但没有发现任何有关此问题的信息?
Dol*_*hin 28
像这样做:
- name: Add hosts to /etc/hosts
run: |
sudo echo "127.0.0.1 postgres.dolphin.com" | sudo tee -a /etc/hosts
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4567 次 |
| 最近记录: |