Now I am using GitHub Actions to build my project. On my local machine, I define the local host address mapping in /etc/hosts like this:
11.19.178.213 postgres.dolphin.com
and in my database config like this:
spring.datasource.druid.post.master.jdbc-url = jdbc:postgresql://postgres.dolphin.com:5432/dolphin
On my production server I could edit the mapping to locate a different IP address of my database. But now I am running unit tests in GitHub Actions. How do I edit the host mapping to make the database mapping to container of GitHub Actions? I defined the container in GitHub Actions like this:
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
What should I do to handle the host mapping? I have already searched the docs, but I have found nothing about this problem?
do it like this:
- name: Add hosts to /etc/hosts
run: |
sudo echo "127.0.0.1 postgres.dolphin.com" | sudo tee -a /etc/hosts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With