mugonat / deploy
Installs: 55
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/mugonat/deploy
Requires (Dev)
- deployer/deployer: ^7.5
README
This repository contains a collection of utility scripts for Deployer, a PHP deployment tool. These scripts streamline common deployment tasks.
composer require mugonat/deploy deployer/deployer --dev
Here's a typical deploy.php
<?php namespace Deployer; require 'recipe/laravel.php'; require 'vendor/mugonat/deploy/utils.php'; // Config set('hook_migrate_auto', true); set('hook_node_modules', true); set('hook_deploy_key', true); add('shared_files', []); add('shared_dirs', []); add('writable_dirs', []); // Hosts host('app.domain.tld') ->set('branch', 'deployment/client') ->set('http_user', 'site-user') ->setRemoteUser('site-user') ->setDeployPath('/home/{{remote_user}}/htdocs/{{hostname}}'); // Hooks after('deploy:failed', 'deploy:unlock'); after('deploy:success', 'artisan:optimize'); after('push', 'artisan:optimize');
Included Files
The utils.php file includes the following files:
env.php
- Purpose: Provides a function
envGet()to read configuration values from a.env.deployerfile in the project root. It prefixes the variable names withDEPLOYER_but also checks for the unprefixed name. - Options: The options are the environment variables themselves, defined in the
.env.deployerfile. The script gives precedence to variables prefixed withDEPLOYER_. - Hooks: None.
git.php
- Purpose: Sets the
repositoryandbranchvariables for Deployer based on environment variables from the.env.deployerfile. - Options:
git_user: The Git user. Defaults todev-mugonat. Can be overridden byDEPLOYER_GIT_USERorGIT_USERin.env.deployer.git_password: The Git password or token. Can be overridden byDEPLOYER_GIT_PASSorGIT_PASSin.env.deployer.git_repo: The Git repository name. Can be overridden byDEPLOYER_GIT_REPOorGIT_REPOin.env.deployer.git_repo_path: The path to the repository on the Git server. Defaults to thegit_user. Can be overridden byDEPLOYER_GIT_REPO_PATHorGIT_REPO_PATHin.env.deployer.git_repo_branch: The branch to deploy. Defaults tomain. Can be overridden byDEPLOYER_GIT_BRANCHorGIT_BRANCHin.env.deployer.git_domain: The Git domain. Defaults togitlab.com. Can be overridden byDEPLOYER_GIT_DOMAINorGIT_DOMAINin.env.deployer.
- Hooks: None.
init.php
- Purpose: Provides initialization tasks for the project.
- Tasks:
env:init: Creates a.env.deployerfile from the example if it doesn't exist.nightwatch:init: Creates a.nightwatchfile from the example if it doesn't exist.utils:init: A meta-task that runsenv:initandnightwatch:init.
- Options: None.
- Hooks: None.
key.php
- Purpose: Defines a task to generate an application key if it's missing in the
.envfile on the server. - Tasks:
deploy:key: Generates the application key.
- Options:
hook_deploy_key: A boolean to enable or disable thebefore('artisan:config:cache', 'deploy:key')hook. Defaults totrue.
- Hooks:
before('artisan:config:cache', 'deploy:key'): This task runs beforeartisan:config:cache.
migrate_auto.php
- Purpose: Defines a task to run "auto" migrations.
- Tasks:
artisan:migrate:auto: Runsphp artisan migrate:auto --force --seed.
- Options:
hook_migrate_auto: A boolean to enable or disable theafter('artisan:migrate', 'artisan:migrate:auto')hook. Defaults totrue.
- Hooks:
after('artisan:migrate', 'artisan:migrate:auto'): This task runs afterartisan:migrate.
nightwatch.php
- Purpose: Contains tasks for validating and configuring Nightwatch, a browser automation testing framework. It sets up a supervisor service to keep the Nightwatch agent running.
- Tasks:
deploy:nightwatch:validate: Checks ifsupervisordis running and if the deploy script is available.deploy:nightwatch: The main task that configures Nightwatch. It creates a configuration file and sets up the supervisor service.deploy:nightwatch:configure: A sub-task ofdeploy:nightwatchthat handles the actual configuration and service setup.
- Options:
nightwatch_port: The port for the Nightwatch service. Defaults to2048. Can be overridden byDEPLOYER_NIGHTWATCH_PORTorNIGHTWATCH_PORTin.env.deployer.supervisor_deploy_script: The path to the supervisor deploy script. Defaults to/usr/local/bin/deploy-supervisor-config.
- Hooks: None.
node_modules.php
- Purpose: Defines a task to install npm dependencies and build the frontend assets.
- Tasks:
deploy:node_modules: Runsnpm installandnpm run build.
- Options:
hook_node_modules: A boolean to enable or disable theafter('deploy:vendors', 'deploy:node_modules')hook. Defaults totrue.
- Hooks:
after('deploy:vendors', 'deploy:node_modules'): This task runs afterdeploy:vendors.