Deployment workflows - davidgb8246/RapidRollout GitHub Wiki

πŸ”„ Deployment Workflows

RapidRollout gives you full control over custom logic during deployments by allowing you to define After Start Script Files. These scripts are executed as root after your application has been initialized.

  • If your project uses Docker Compose, scripts will run after docker compose up -d has completed.
  • If not, they’ll run after the repository has been downloaded and all private files have been saved to the system.

This allows you to execute service configurations, migrations, or any system-level commands in a reliable and automated way.


🧩 What Is an After Start Script?

An After Start Script File is a special type of private file that runs automatically during key deployment events. These are defined in the Private Files section by selecting the file type after-start-script.


🚦 When Scripts Run

These scripts are triggered during three types of events:

Event Description
PROJECT_DEPLOY When a new deployment is triggered (on git push)
PROJECT_REBOOT When a reboot is manually initiated from the dashboard
PROJECT_REBUILD When a rebuild is manually initiated from the dashboard

βœ… All scripts run with bash and root permissions, so you have full control over system-level operations.


πŸ“€ Input Passed to Scripts

Each script receives a JSON payload via stdin, which provides context about the event that triggered the execution.

πŸ›  Payload Format

For PROJECT_DEPLOY:

{
  "user": "deploy-user-abc123",
  "action": "PROJECT_DEPLOY",
  "deployment_id": "a1b2c3d4-e5f6-7890-1234-abcdef123456"
}

For PROJECT_REBOOT and PROJECT_REBUILD:

{
  "user": "deploy-user-abc123",
  "action": "PROJECT_REBOOT" // or PROJECT_REBUILD
}

You can access and parse this input in your script using common shell tools.

πŸ“¦ Example usage in script:

#!/bin/bash

# Parse JSON input argument into associative array
json_arg="$1"

# Declare associative array
declare -A data

# Populate the array using jq safely
while IFS="=" read -r key value; do
  data["$key"]="$value"
done < <(echo "$json_arg" | jq -r 'to_entries[] | "\(.key)=\(.value)"')

echo "Running ${data["action"]} for user ${data["user"]}"

πŸ›  Sending Deployment Debug Messages

When running an After Start Script File during a project deployment, you can send debug or status messages to RapidRollout using a built-in endpoint:

POST /api/management/addDeploymentStatusMessage/

πŸ”’ Requirements

This endpoint should only be used during project deployments, as the messages must be linked to a specific deployment via its UUID.

Required Parameters:

  • deployment_id (string): The UUID of the active deployment.
  • secret (string): The project’s secret key, generated during project creation or manually reset from the dashboard.
  • message (string): The message you want to log for debugging or informational purposes.

πŸ“¦ Example Payload (JSON)

{
  "deployment_id": "123e4567-e89b-12d3-a456-426614174000",
  "secret": "your-project-secret-key",
  "message": "Finished running setup.sh successfully."
}

βœ… Use Cases

  • Reporting progress of post-deployment tasks.
  • Logging outputs or important checkpoints for debugging.
  • Letting the dashboard reflect detailed messages during setup.

⚠️ Note: Do not use this endpoint for rebuild or reboot actions, as those do not generate a deployment_id and cannot accept messages.


βœ… Tips

  • Scripts should be safe to run multiple times without causing errors or unexpected behavior.
  • Test your scripts thoroughly before adding them.
  • You can use this to configure services, restart daemons, run migrations, or anything your app needs post-startup.

🚧 Permissions & Security

  • Scripts are executed as root, so use caution.
  • Make sure the script files have execute permissions (e.g., 755).
  • Never expose sensitive logic or secrets directly in scripts.

By using these After Start Scripts, RapidRollout gives you the flexibility to adapt your deployments to your app's unique infrastructure needs.