Skip to content

Instantly share code, notes, and snippets.

@JJCLane
Last active January 28, 2019 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JJCLane/259f1b3d2d5f90199c2637264025c6c0 to your computer and use it in GitHub Desktop.
Save JJCLane/259f1b3d2d5f90199c2637264025c6c0 to your computer and use it in GitHub Desktop.
Setting up CI for projects

Initial Setup

  • Copy .circleci folder from a previous project
  • Run composer require deployer/recipes --dev to install the required rysnc Deployer recipe
  • Copy deploy.php from the root directory of a previous project
  • Create a .env.testing file based on the .env.example but replace the following properties:
APP_ENV=testing
APP_DEBUG=true
APP_LOG_LEVEL=debug

DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=:memory:
DB_USERNAME=circleci
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync

Configuration

  • Edit the deploy.php file
  • Set the application name to a logical name (this will be used for the folder name on the server in public_html)
  • Update the repository URL to the new one which can be found by clicking on clone within the repo on Bitbucket
  • Add any folders that should remain between deployments to the shared_dirs function e.g. a folder with a lot of photos which wouldn't be in the git repo
  • Check that the appropriate files and folders are within the exclude list (these will not be transferred from the build server to the production server)
  • If the application will live under a separate cPanel account, change the user property under each host to match the account name. You would also need to copy the files from the .ssh directory under the previous account to the new account, or create new keys and add the key to the CircleCI account to get the fingerprint and replace the current fingerprint in .circleci/config.yml
  • If you are using Laravel Telescope, make sure to add <env name="TELESCOPE_ENABLED" value="false"/> to phpunit.xml so that tests will pass
  • Commit the changes you've made and push them to the repo

First Run

  • Log in to CircleCI with your Bitbucket account
  • Click on Set up project within Add Projects, and then click on Start Building
  • Open up the settings for the project, and click on SSH Permissions, add the SSH private key with a hostname that matches the deploy.php hostname
  • Trigger a build or push a commit and monitor the output on CircleCI
  • SSH onto the server and cd into the shared directory to edit the .env file with appropriate values

Then you should be good to go!

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