Use Deployer’s lifecycle events to publish a start signal, then resolve the same DeployState step when the deployment is successful or fails.
01 / Configure the platform
Put the hook beside the deployment work.
Find deploy.php. The exact commands stay in the tool you already trust; DeployState only receives the lifecycle signal before and after it runs.
-
01
Expose the private URL to Deployer
Set DEPLOYSTATE_HOOK_URL in the environment that runs deploy.php, such as your CI secret store or local shell profile.
-
02
Add three tiny tasks
Each task sends one lifecycle action to the same private hook base URL. Keep the URL out of version control.
-
03
Attach the lifecycle events
The start task runs before the deployment prepares. Complete and fail tasks follow Deployer’s own final events.
02 / PHP example
A single private base URL, three possible states.
Attach the start task before deploy:prepare. Resolve after deploy:success or deploy:failed so DeployState matches Deployer’s final outcome.
DEPLOYSTATE_HOOK_URL<?php
use function Deployer\run;
set('deploystate_hook_url', getenv('DEPLOYSTATE_HOOK_URL'));
task('deploystate:start', function (): void {
run('curl --fail --silent --show-error -X POST "{{deploystate_hook_url}}/start"');
});
task('deploystate:complete', function (): void {
run('curl --fail --silent --show-error -X POST "{{deploystate_hook_url}}/complete"');
});
task('deploystate:fail', function (): void {
run('curl --fail --silent --show-error -X POST "{{deploystate_hook_url}}/fail"');
});
before('deploy:prepare', 'deploystate:start');
after('deploy:success', 'deploystate:complete');
after('deploy:failed', 'deploystate:fail');
Set DEPLOYSTATE_HOOK_URL to the private URL copied from a step, for example https://your-deploystate-url/api/v1/hooks/{step-token}. Append /start, /complete, or /fail exactly as shown.
If you choose a readable endpoint, store its URL and token separately: DEPLOYSTATE_HOOK_URL=https://your-deploystate-url/api/v1/production/deploy and DEPLOYSTATE_HOOK_KEY={step-token}, then add -H "X-DeployState-Key: $DEPLOYSTATE_HOOK_KEY" to each curl call.
03 / Protect the signal
Keep the credential in the platform’s secret store.
- Do not paste a private hook into source control, an issue, or build output.
- For a readable endpoint, keep
DEPLOYSTATE_HOOK_KEYprivate even though the URL itself is safe to read. - Give each deploy concern its own step so one integration never needs another integration’s credential.
- Rotate the hook from the DeployState step editor if it is exposed or no longer needed.
Ready to test