From a4b8d812d4e0b8eb4b2da5679d5ee3d75a1b15c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bonhomme?= Date: Tue, 17 Dec 2019 11:00:07 +0100 Subject: [PATCH] Upgrading databases and creating initial user. Set MONARC configuration file. --- .github/workflows/php.yml | 44 +++++++++++++++++++--------------- config/autoload/local.php.dist | 12 +++------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 3d0e8fa..c5810a7 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -16,20 +16,20 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Shutdown Ubuntu MySQL (SUDO) - run: sudo service mysql stop + #- name: Shutdown Ubuntu MySQL (SUDO) + #run: sudo service mysql stop - - name: Start MariaDB and create databases - uses: getong/mariadb-action@v1.1 - with: - host port: $MYSQL_HOST_PORT - mysql database: $MYSQL_DATABASE # Optional, default value is "test". The specified database which will be create - mysql root password: $MYSQL_ROOT_PASSWORD # Required if "mysql user" is empty, default is empty. The root superuser password - mysql user: $MYSQL_USER # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too - mysql password: $MYSQL_PASSWORD # Required if "mysql user" exists. The password for the "mysql user" + #- name: Start MariaDB and create databases + #uses: getong/mariadb-action@v1.1 + #with: + #host port: $MYSQL_HOST_PORT + #mysql database: $MYSQL_DATABASE # Optional, default value is "test". The specified database which will be create + #mysql root password: $MYSQL_ROOT_PASSWORD # Required if "mysql user" is empty, default is empty. The root superuser password + #mysql user: $MYSQL_USER # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too + #mysql password: $MYSQL_PASSWORD # Required if "mysql user" exists. The password for the "mysql user" - - name: Start MySQL (SUDO) - run: sudo service mysql start + #- name: Start MySQL (SUDO) + #run: sudo service mysql start - name: Setup PHP uses: shivammathur/setup-php@v1 @@ -40,9 +40,6 @@ jobs: coverage: xdebug #optional, setup coverage driver pecl: false #optional, setup PECL - # - name: Install PHP extensions - # run: sudo apt-get install -y php apache2 libapache2-mod-php php-curl php-gd php-mysql php-pear php-apcu php-xml php-mbstring php-intl php-imagick php-zip - - name: Validate composer.json and composer.lock run: composer validate @@ -57,17 +54,26 @@ jobs: ln -s ./../../vendor/monarc/frontoffice FrontOffice cd ../.. + - name: Set MONARC configuration file + run: cp ./config/autoload/local.php.dist ./config/autoload/local.php + - name: Populating common database run: | mysql -u root -p$MYSQL_ROOT_PASSWORD -P $MYSQL_HOST_PORT -e "CREATE DATABASE monarc_common DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" - mysql -u root -p$MYSQL_ROOT_PASSWORD -P $MYSQL_HOST_PORT -e "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD ';" + mysql -u root -p$MYSQL_ROOT_PASSWORD -P $MYSQL_HOST_PORT -e "CREATE DATABASE monarc_cli DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" + mysql -u root -p$MYSQL_ROOT_PASSWORD -P $MYSQL_HOST_PORT -e "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" mysql -u root -p$MYSQL_ROOT_PASSWORD -P $MYSQL_HOST_PORT -e "GRANT ALL PRIVILEGES ON * . * TO '$MYSQL_USER'@'%';" mysql -u root -p$MYSQL_ROOT_PASSWORD -P $MYSQL_HOST_PORT -e "FLUSH PRIVILEGES;" - mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -P $MYSQL_HOST_PORT $MYSQL_DATABASE < db-bootstrap/monarc_structure.sql > /dev/null - mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -P $MYSQL_HOST_PORT $MYSQL_DATABASE < db-bootstrap/monarc_data.sql > /dev/null - + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -P $MYSQL_HOST_PORT $MYSQL_DATABASE < db-bootstrap/monarc_structure.sql + mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -P $MYSQL_HOST_PORT $MYSQL_DATABASE < db-bootstrap/monarc_data.sql + - name: Upgrading databases + run: | + ./vendor/robmorgan/phinx/bin/phinx migrate -c ./module/Monarc/Core/migrations/phinx.php + ./vendor/robmorgan/phinx/bin/phinx migrate -c ./module/Monarc/FrontOffice/migrations/phinx.php + - name: Creating initial user + run: ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/Monarc/FrontOffice/migrations/phinx.php # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" # Docs: https://getcomposer.org/doc/articles/scripts.md diff --git a/config/autoload/local.php.dist b/config/autoload/local.php.dist index 4448862..ec774d4 100644 --- a/config/autoload/local.php.dist +++ b/config/autoload/local.php.dist @@ -10,13 +10,7 @@ * in ZendSkeletonApplication. This is a good practice, as it prevents sensitive * credentials from accidentally being committed into version control. */ - - $appdir = getenv('APP_DIR') ? getenv('APP_DIR') : '/var/lib/monarc/fo'; - $string = file_get_contents($appdir.'/package.json'); - if($string === FALSE) { - $string = file_get_contents('./package.json'); - } - $package_json = json_decode($string, true); +$package_json = json_decode(file_get_contents('./package.json'), true); return array( 'doctrine' => array( @@ -24,7 +18,7 @@ return array( 'orm_default' => array( 'params' => array( 'host' => 'localhost', - 'user' => 'root', + 'user' => 'sqlmonarcuser', 'password' => 'password', 'dbname' => 'monarc_common', ), @@ -32,7 +26,7 @@ return array( 'orm_cli' => array( 'params' => array( 'host' => 'localhost', - 'user' => 'root', + 'user' => 'sqlmonarcuser', 'password' => 'password', 'dbname' => 'monarc_cli', ),