I’m trying to create an action to run a set of E2E tests against WordPress instance which is running _inside_ action context.
It works fine when everything is set up inside the host VM, but when I trying to take advantage of services, it just does not work.
The problem is that I need to link two services together. Without this, Wordpress container can not communicate with MySQL container: Can't connect to MySQL server
name: E2E tests
on: push
env:
DB_NAME: jetpack_test
DB_HOST: 127.0.0.1
DB_USERNAME: root
DB_PASSWORD: root
jobs:
wp:
runs-on: ubuntu-latest
# Service containers to run with `container-job`
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: jetpack_test
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
wp:
image: wordpress
ports:
- 8080:80
options: --name wpcnt
wp-cli:
image: wordpress:cli
options: --name wpcli
steps:
- uses: actions/checkout@v2
- name: setup WordPress
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
run: |
CLI_CMD="docker run -it --rm --volumes-from wpcnt --network container:wpcnt wordpress:cli"
$CLI_CMD core config --dbname=$DB_NAME --dbuser=$DB_USERNAME --dbpass=$DB_PASSWORD --dbhost=$DB_HOST:$DB_PORT --dbprefix=wp_