Deploy to Production#
Follow this process once a feature is approved and we're ready to deploy to production.
Merge Feature into Develop#
When a feature branch is approved, merge it into develop branch so everyone can pull from the most up to date codebase.
- Go to the npl-d8 project in Github: NPLD-8
- Verify the pull request is ready to merge (merge pull request button should be green).
- Click the “Merge Pull Request” button.
- In the box above the “Confirm Merge” button, type the ticket IDs covered with this merge.
- Click the “Confirm Merge” button.
- Delete the branch in Github.
Merge Develop into Master#
When you are ready to deploy changes to Pantheon, merge develop into master using either the Github GUI or Terminal, then push to Pantheon.
Use Terminal (recommended)#
- Go to develop branch:
git checkout develop
- Pull to get most up to date develop code:
git pull origin develop
- Checkout master:
git checkout master
- Pull to get most up to date master code:
git pull origin master
- Merge develop into master:
git merge develop
- If you end up in VIM, do esc, colon, write, quit:
esc button then:wq
- Push to Pantheon:
git push origin master
- Go to GitHub Actions, to see the build process run. The build process deploys master to Pantheon dev.
Use the Github GUI (alternate option)#
- Go to the npl-d8 project in Github: NPLD-8
- Click the Pull Requests tab.
- Click the New Pull Request button.
- For “comparing changes” options:
- Base = master
- Compare = develop
- Review the commits that are going into this pull request just to be sure it is what you expected.
- Click the “Create Pull Request” button.
- Type the release number in the title: Build x.x.xx
- Check Pantheon dev to see what release number we’re on.
- Minor release numbers go to 20 then you start a new major release.
- Click the “Create Pull Request” button.
- Click the “Merge Pull Request” button.
- Go to GitHub Actions, to see the build process run. The build process deploys master to Pantheon dev.
Review on Pantheon#
Once code is on Pantheon, test on dev and test sites before deploying to live.
Make a Backup of Live#
- Log in to Pantheon: Pantheon
- Click the Live tab.
- Click the Backups option from the left menu.
- Start a backup. A backup is a good idea before a deploy to live. Start the backup now b/c it may take a while.
Review on Dev#
- Log in to Pantheon: Pantheon
- Click the Dev tab.
- Click the link to visit the dev site.
- Verify that the changes from the feature branch are all present and functioning correctly.
- If all looks good, click on the Test tab.
Deploy from Dev to Test#
- On the Test tab, write a deploy message. Include the build number, like this: "Deploy build x.x.x: Updates to X Y Z."
- Make sure all the checkboxes for the deploy are checked: run update.php, clear caches, pull files and database from live.
- Click the “deploy code from dev to test” button.
- Click the link to visit the test site.
- Verify that the changes are all present and behaving correctly.
- As you are testing, write down any deploy steps you need to repeat on live.
- If all looks good, click on the Live tab.
Deploy from Test to Live#
- If all changes look good on test, click the live tab.
- Verify that your backup is finished.
- Click the “deploy code from test to live” button.
- Visit the live site.
- Verify the site is up.
- Verify that the changes are all present and behaving correctly.
- If all looks good, you’re done! If all is NOT good, see “troubleshooting” steps below.
Troubleshooting#
Issues Merging Feature into Develop#
Note, if you run into trouble during the merge, you might have issues with the composer.lock file and the hash in the file. You may not be able to use the Github interface completely because sometimes you have to run “composer update --lock” if there are merge conflicts with composer.
Issues Merging Develop into Master#
Master branch shouldn’t have a build failure, but it is possible.
If the build process fails when you’re on the master branch:
- Go to Terminal.
- Do pull:
git pull origin master
- Do config import:
ddev drush cim
ORlando drush cim
- Update the lock file: composer update --lock
- Make sure hash files are not conflicting.
- Fix anything on master that is weird, fix it on master, commit changes, and then push to master.
If you make changes on master, you have to put all changes in develop once everything is fixed:
- cd into develop
- remerge changes from master into develop: git merge master
- Push changes to develop: git push origin develop
- Deploy Changes on Pantheon
Config Will Not Import on Pantheon Dev#
When pushing from local to Pantheon Dev, you might run into a scenario where config won't import. This often happens when there are core updates and lines of code are moved around, but not really changed.
- Import config.
- Try importing config via terminus.
terminus drush npl-d8.dev -- cim
- Try importing config via the UI.
- Try importing config via terminus.
- If config changes aren't imported, go to admin/config/development/configuration and click "view differences" next to several of the configurations.
- If the left and right side code is the same, but just in different position in the list, re-export config on local and push back up.
- Go to local.
- On develop, pull code and import config.
git pull origin develop
ddev drush cim
ORlando drush cim
- After import is complete, export config.
ddev drush cex
ORlando drush cex
- If there are changes to export, go ahead and commit those.
- Push code to origin develop.
git push origin develop
- Check out master and merge deveop.
git checkout master
git merge develop
- Push code to origin master.
git push origin master
- Go to Pantheon Dev and verify that config is imported on this page: admin/config/development/configuration
Issues Deploying to Live#
"Error: The website encountered an unexpected error. Try again later."
- This error can happen when configurations aren’t imported.
- If the site goes unresponsive the only way to interact with it, is using Drush via terminus.
Step-by-Step Fix:
- Check if the site schema has been updated as this can cause fatal errors because queries are more or less breaking because it can’t find database tables.
terminus drush npl-d8.dev -- updb
terminus drush npl-d8.test -- updb
terminus drush npl-d8.live -- updb
- If that doesn’t work then try reimporting the configuration again.
terminus drush npl-d8.dev -- cim
terminus drush npl-d8.test -- cim
terminus drush npl-d8.live -- cim
- After importing you’ll need to clear the cache.
terminus drush npl-d8.dev -- cr
terminus drush npl-d8.test -- cr
terminus drush npl-d8.live -- cr
DDEV will not launch a local development environment#
- run
docker ps -a
- This will list all docker containers.
- run
docker stop $(docker ps -aq)
- This will quit all docker containers.
- run
docker rm
, followed by each listed container number - e.g.
docker rm 9c19ae5535ff d05fc97f7731 ec06144d1c03 02ae900eda16 533c286f4556