Skip to content

Instantly share code, notes, and snippets.

@azharuddinkhan3005
Last active April 1, 2019 11:48
Show Gist options
  • Save azharuddinkhan3005/c3fbf22ecc5a3c298abb6bbe98fc1e6d to your computer and use it in GitHub Desktop.
Save azharuddinkhan3005/c3fbf22ecc5a3c298abb6bbe98fc1e6d to your computer and use it in GitHub Desktop.
TMT Admin

Before we start any of the operations (on your host system) please run these two steps

git config --global user.email "<your github email ID>"
git config --global user.name "<your github username>"

If done earlier then leave it!

Carrying on..

  1. We need to have the workflow for TMT Admin in conjunction with GitHub.(https://github.com/srijanaravali/tmtbe)

  2. Clone the repository https://github.com/srijanaravali/tmtbe into web > tmtadmin.

Here the web folder resides within the folder which contains all tmt related docker files. For example your root folder is tmt then the tmtadmin folder should be present at tmt>web>tmtadmin
  1. After cloning the above repository navigate to the tmtadmin folder from your terminal and

    • run composer install. This will take a while.
    • Then within that directory run git config core.fileMode false.
  2. In the tmtadmin directory's root create a copy of .env.example with the name .env and place the following code in it.

    • MYSQL_DATABASE=tmtd8_db
      MYSQL_HOSTNAME=db
      MYSQL_PASSWORD=tmtdevpass
      MYSQL_PORT=3306
      MYSQL_USER=tmtdevuser
      
      APP_ENV='local'
      
  3. Create a copy of /tmtadmin/web/sites/example.settings.local.php as /tmtadmin/web/sites/default/settings.local.php and at the end of the newly created settings.local.php file place the following code:

    • $databases['default']['default'] = [
       'database' => getenv('MYSQL_DATABASE'),
       'driver' => 'mysql',
       'host' => getenv('MYSQL_HOSTNAME'),
       'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
       'password' => getenv('MYSQL_PASSWORD'),
       'port' => getenv('MYSQL_PORT'),
       'prefix' => '',
       'username' => getenv('MYSQL_USER'),
      ];
      
  4. Note: this step should be done after we have created all the docker containers

    • Navigate to http://localhost:8089/admin/tmt, it will present the drupal installation screen
    • Select English and then click on Save and continue
    • In the next screen select the profile as Standard and click on Save and continue
    • In the next screen, for database configuration enter the following:
      • Database name: tmtd8_db
      • Database username: tmtdevuser
      • Database password: tmtdevpass
      • Click on Advanced options and enter the Host as db and Port Number as 3306 and click on Save and continue and it will install Drupal!
      • In the next screen enter the configuration details and click on Save and Continue and then we will land on the Drupal homepage!
  5. Edit the settings.php present at tmtadmin/web/sites/default and remove the following lines present at EOF

    • $databases['default']['default'] = [
        'database' => 'tmtd8_db',
        'username' => 'tmtdevuser',
        'password' => 'tmtdevpass',
        'prefix' => '',
        'host' => 'db',
        'port' => '3306',
        'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
        'driver' => 'mysql',
      ];
      $config_directories['sync'] = 'sites/default/files/config_Ja-S9_5MGG9EGCjhn5KYVfbvfdR7J6VyPDx_pbgrhbF6D077-xuhTfT1--CFLMSNTjudfUTqrA/sync';
      
    • And then add the following lines at the end

      • $env = getenv('APP_ENV');
        $base_path = $app_root . '/' . $site_path;
        $settings_file = $base_path . '/settings.' . $env . '.php';
        
        if (file_exists($settings_file)) {
          include $settings_file;
        }
        if ($env === 'local') {
          $config['config_split.config_split.config_dev']['status'] = TRUE;
        }
        else {
          $config['config_split.config_split.config_dev']['status'] = FALSE;
        }
        $config_directories['sync'] = '../config/sync';
        
  6. Edit the development.services.yml file present at tmntadmin/web/sites and under the parameters add:

    • twig.config:
        debug: true
        auto_reload: true
        cache: false
      
  7. When we go to our local repository and run git remote -v then we get this

    • origin	git@github.com:srijanaravali/tmtbe.git (fetch)
      origin	git@github.com:srijanaravali/tmtbe.git (push)
      
    • So this means we have only one remote added which is the GitHubs's srijanaravali one.
  8. Need to pull in the develop and npn branches from github's remote.

    • git fetch origin
      git checkout develop
      git checkout master
      git checkout npn
      
    • This ensures we have github remote's develop and npn branch on our local so now switch back to the master branch (git checkout master).
  9. Now for developing your ticket firstly create a new branch while being on master.

    • (All new branches should be made from master)

    • Suppose the ticket that you are working on is TMT-89 then create a new branch with the name TMT-89 by
      • git checkout master
        git checkout -b tmt-89
        
  10. After you have done all your development on this ticket add all the files to be commited, commit all the files to be commited and lastly push this ticket to GitHub

    • git add <your files>
      git commit -m "<give a proper comment>"
      git push origin tmt-89
      
    • Please follow this commit commenting pattern.
      • Ticket #<Ticket number> <Your comment.>
      • Example: Ticket #TMT-89 This is my test comment.
  11. Then go to your GitHub repo on browser (https://github.com/srijanaravali/tmt_admin) and there you will be prompted to create a pull request (PR) (click on the Compare & Pull request). After clicking on the Compare & Pull request button we will be taken to another page where we will be given a button to Create pull request. Click on it and your pull request will be created. Then assign it to a Reviewer.

  12. Then in order to unit test our changes on dev env we need to merge github's ticket (in this case it is tmt-89) branch into develop branch.

    • git checkout develop
      git pull origin tmt-89
      git push origin develop
      
    • Then goto https://TBD(to be decided) to test your changes.
  13. Then in order to QA our changes on npn env we need to checkout to the branch stage and pull all the changes made in your ticket(TMT 89) into this branch and push it to GitHub

    • git checkout stage
      git pull github tmt-89
      git push origin stage
      
    • Then goto https://TBD(to be decided) to test your changes.
  14. Once the QA approves it your ticket will be merged into GitHub master and consequently to prod env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment