forked from mirromutth/mysql-action
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now supports root superuser, ports and charset options.
- Loading branch information
1 parent
9e1c6ff
commit 73a5ef7
Showing
2 changed files
with
53 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
#!/bin/sh | ||
|
||
docker_run="docker run -e MYSQL_RANDOM_ROOT_PASSWORD=true" | ||
docker_run="$docker_run -e MYSQL_DATABASE=$INPUT_MYSQL_DATABASE" | ||
docker_run="$docker_run -e MYSQL_USER=$INPUT_MYSQL_USER" | ||
docker_run="$docker_run -e MYSQL_PASSWORD=$INPUT_MYSQL_PASSWORD" | ||
docker_run="$docker_run -d -p 3306:3306 mysql:$INPUT_MYSQL_VERSION" | ||
docker_run="docker run" | ||
|
||
if [ -n "$INPUT_MYSQL_ROOT_PASSWORD" ]; then | ||
echo "Root password not empty, use root superuser" | ||
|
||
docker_run="$docker_run -e MYSQL_ROOT_PASSWORD=$INPUT_MYSQL_ROOT_PASSWORD" | ||
elif [ -n "$INPUT_MYSQL_USER" ]; then | ||
if [ -z "$INPUT_MYSQL_PASSWORD" ]; then | ||
echo "The mysql password must not be empty when mysql user exists" | ||
exit 1 | ||
fi | ||
|
||
echo "Use specified user and password" | ||
|
||
docker_run="$docker_run -e MYSQL_RANDOM_ROOT_PASSWORD=true -e MYSQL_USER=$INPUT_MYSQL_USER -e MYSQL_PASSWORD=$INPUT_MYSQL_PASSWORD" | ||
else | ||
echo "Both root password and superuser are empty, must contains one superuser" | ||
exit 1 | ||
fi | ||
|
||
if [ -n "$INPUT_MYSQL_DATABASE" ]; then | ||
echo "Use specified database" | ||
|
||
docker_run="$docker_run -e MYSQL_DATABASE=$INPUT_MYSQL_DATABASE" | ||
fi | ||
|
||
docker_run="$docker_run -d -p $INPUT_HOST_PORT:$INPUT_CONTAINER_PORT mysql:$INPUT_MYSQL_VERSION --port=$INPUT_CONTAINER_PORT" | ||
docker_run="$docker_run --character-set-server=$INPUT_CHARACTER_SET_SERVER --collation-server=$INPUT_COLLATION_SERVER" | ||
|
||
sh -c "$docker_run" |