Ever used a IaaS provider like Vercel, Netlify or Railway and loved how automagically your code gets deployed as soon as you push to the repository? Well, now you can do the same with Deployinator, a lightweight deployment server built using the Gin web framework for Go.
It listens for incoming deployment requests from GitHub Webhooks, validates them using HMAC signatures, and triggers corresponding deployment scripts for different projects.
- Secure deployment using HMAC SHA256 signatures
- Easy-to-extend with deployment scripts
- You'll never have to worry about a random $10k bill ever again.
- Go (version 1.21 or above)
- Bash
-
Clone the repository:
git clone https://github.com/yourusername/deployinator.git cd deployinator -
Install dependencies:
go mod tidy
-
Create a
.envfile with the following content:GIN_MODE=release SECRET_KEY=super_secret_key
-
Create your deployment scripts inside the
deploy_scriptsdirectory. Each script should be named after the project it deploys, e.g.,my_project.sh. -
Build and run the application:
go build -o deployinator ./deployinator
GIN_MODE: Sets the Gin mode. Options aredebug,release, andtest.SECRET_KEY: A secret key used to validate incoming deployment requests from GitHub.
- Deployinator listens on port
4444by default. - To trigger a deployment, GitHub Webhooks should be configured to send a POST request to
http://yourdomain.com/<projectName>with the HMAC SHA256 signature header.
- Go to your GitHub repository and navigate to Settings > Webhooks.
- Click Add webhook.
- In the Payload URL field, enter
http://yourdomain.com/<projectName>, replacing<projectName>with the name of your project. - Set the Content type to
application/x-www-form-urlencoded. - In the Secret field, enter the
SECRET_KEYfrom your.envfile. - Choose the events you want to trigger the webhook. Typically, Push events are used for deployments.
- Click Add webhook to save your settings.
Deployment scripts should be placed in the deploy_scripts directory and should be named according to the project they deploy. For example, a script for the project my_project should be named my_project.sh.
#!/bin/bash
# Example deployment script for my_project
echo "Deploying my_project"
# Add your deployment commands hereMake sure your scripts are executable:
chmod +x deploy_scripts/*.shDeployinator uses HMAC SHA256 to verify the authenticity of the deployment requests from GitHub. Ensure that your SECRET_KEY is kept secure and never exposed in your code or logs.
Deployinator is open-sourced software licensed under the MIT license.
Contributions are welcome! Please submit a pull request or open an issue to discuss your changes.