How to pass "mysql_native_password" to MySQL service in GitHub Actions?
Currently its not possible to specify command option in github actions service workflow syntax, a simpler alternative is to use a different mysql image and override the entrypoint to use native password, or use an existing image that provides configuring auth method using env variables like this bitnami mysql image.
Using the bitnami mysql image:
services:
mysql:
image: bitnami/mysql:8.0.20
env:
ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: abc
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
ports:
- 3306/tcp
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
The issue is that GH actions does not move --entrypoint
option and related arguments to the end of the command but instead it appends other options like env. variables specified in env
service
section after it.
After a lot of trial and errors I found out, you can specify the env. vars manually, command like this is working:
...
services:
mysql:
image: mysql:8
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=xxx -e MYSQL_USER=xxx -e MYSQL_PASSWORD=xxx -e MYSQL_DATABASE=xxx --entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
steps:
...