# evennia/setup-database # Use this action in a workflow for when you need to do initialization of database services # (such as with PostgreSQL and MySQL) before you initiate unit tests that will employ that # database service. # NOTE: This action was intended for use with the core Evennia workflows ONLY. name: Set up Evennia database service author: dvoraen description: "Activates the database server for the passed in service and ensures it's ready for use." inputs: database: description: "Database service being initialized." required: true runs: using: "composite" steps: - name: Wait for PostgreSQL to be ready if: ${{ inputs.database == 'postgresql' }} run: | # Wait for PostgreSQL service container to be healthy until pg_isready -h localhost -U evennia -d evennia; do sleep 1 echo -n . done echo "PostgreSQL is ready" shell: bash env: PGPASSWORD: password - name: Wait for MySQL to be ready if: ${{ inputs.database == 'mysql' }} run: | # Wait for MySQL service container to be healthy until mysqladmin ping -h 127.0.0.1 -u root -proot_password --silent; do sleep 1 echo -n . done echo "MySQL is ready" shell: bash - name: Set up MySQL Configuration and Privileges if: ${{ inputs.database == 'mysql' }} run: | # Create MySQL config file inside the container and restart MySQL to apply settings # This ensures settings are applied at server startup, similar to command-line arguments CONTAINER_ID=$(docker ps --filter "ancestor=mysql:8.0" --format "{{.ID}}" | head -1) if [ -n "$CONTAINER_ID" ]; then # Create config file in container docker exec $CONTAINER_ID sh -c 'printf "[mysqld]\ncharacter-set-server=utf8mb4\ncollation-server=utf8mb4_unicode_ci\ninnodb-default-row-format=DYNAMIC\n" > /etc/mysql/conf.d/custom.cnf' # Restart MySQL to apply config (graceful shutdown and start) docker exec $CONTAINER_ID sh -c 'mysqladmin -u root -proot_password shutdown' || true sleep 2 docker start $CONTAINER_ID # Wait for MySQL to be ready again until mysqladmin ping -h 127.0.0.1 -u root -proot_password --silent; do sleep 1 echo -n . done fi # Also set global variables as a fallback (though config file should handle this) mysql -u root -proot_password -h 127.0.0.1 mysql <