mugonat / deploy
There is no license information available for the latest version (0.1.0) of this package.
0.1.0
2025-10-03 06:04 UTC
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.deployer
file 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.deployer
file. The script gives precedence to variables prefixed withDEPLOYER_
. - Hooks: None.
git.php
- Purpose: Sets the
repository
andbranch
variables for Deployer based on environment variables from the.env.deployer
file. - Options:
git_user
: The Git user. Defaults todev-mugonat
. Can be overridden byDEPLOYER_GIT_USER
orGIT_USER
in.env.deployer
.git_password
: The Git password or token. Can be overridden byDEPLOYER_GIT_PASS
orGIT_PASS
in.env.deployer
.git_repo
: The Git repository name. Can be overridden byDEPLOYER_GIT_REPO
orGIT_REPO
in.env.deployer
.git_repo_path
: The path to the repository on the Git server. Defaults to thegit_user
. Can be overridden byDEPLOYER_GIT_REPO_PATH
orGIT_REPO_PATH
in.env.deployer
.git_repo_branch
: The branch to deploy. Defaults tomain
. Can be overridden byDEPLOYER_GIT_BRANCH
orGIT_BRANCH
in.env.deployer
.git_domain
: The Git domain. Defaults togitlab.com
. Can be overridden byDEPLOYER_GIT_DOMAIN
orGIT_DOMAIN
in.env.deployer
.
- Hooks: None.
init.php
- Purpose: Provides initialization tasks for the project.
- Tasks:
env:init
: Creates a.env.deployer
file from the example if it doesn't exist.nightwatch:init
: Creates a.nightwatch
file from the example if it doesn't exist.utils:init
: A meta-task that runsenv:init
andnightwatch:init
.
- Options: None.
- Hooks: None.
key.php
- Purpose: Defines a task to generate an application key if it's missing in the
.env
file 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 ifsupervisord
is 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:nightwatch
that handles the actual configuration and service setup.
- Options:
nightwatch_port
: The port for the Nightwatch service. Defaults to2048
. Can be overridden byDEPLOYER_NIGHTWATCH_PORT
orNIGHTWATCH_PORT
in.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 install
andnpm 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
.