A Dead Simple Deployment Command
I have a couple personal projects which I wanted to automate the deployment of, whose deployment procedure is just to copy and overwrite the files. To do this I used to SCP the new files to the web directory on my server. In order to automate it I recently wrote SimpleDeployer.
SimpleDeployer is indeed simple and dumb. It reads from a predefined yaml config file and for each entry it clones the given Git repository and then copies files from the repository into the defined output directory.
To be the slightest bit useful it required a couple more features: ignore, noOverwrite, and postInstall. Ignore allows you to never copy files from the repository into the output directory. noOverwrite lets you copy files from the repository to the output, but only if they don’t exist in the output already. And, finally, postInstall can be used to run any script after the copy is complete.
The config file will be located at ~/.deployer/deployer.yaml. Here’s an example of the config I’m using:
definitions: - ignore: - .*/* outDir: /var/www/html/mikedombrowski/sched repository: https://github.com/MikeDombo/Schedule-Generator-PHP.git sourceDir: ./src/ postInstall: - chmod -R 755 . - composer install - chown -R www-data:www-data . - ignore: - .*/* noOverwrite: - config.php - views/home.pug - importer/upload.php outDir: /var/www/html/mikedombrowski/ur repository: https://github.com/MikeDombo/university-schedule-generator.git sourceDir: ./src/ postInstall: - chmod -R 755 . - composer install - chown -R www-data:www-data . - ignore: - .*/* - "*ffmpeg.exe" noOverwrite: - "*.htaccess" outDir: /var/www/html/ytpod repository: https://github.com/MikeDombo/AudioDidact.git sourceDir: ./src/ postInstall: - chmod -R 755 . - composer install - chown -R www-data:www-data .
SimpleDeployer is written in Python and thus can be easily installed to your path by running python setup.py install after cloning the project.
I’m looking for a better name, so if you have one please comment below or open an issue on the GitHub. I’m also always open to pull requests if you wanted to make the project a bit smarter (ie. save the last downloaded commit hash so that it doesn’t overwrite the local files even when the Git didn’t update).
Leave a Reply