From Scratch to Seamless, Self-Hosted Automated Git Deployments
Ensure your local development repository is clean, structured properly, and clear of environment noise before pushing to the cloud.
glep/
├── .github/
│ └── workflows/
│ └── deploy.yml
├── commands/
├── utils/
├── index.js
├── package.json
└── .gitignore
Verify your root workspace files contain these exact properties:
.gitignore (Keeps system nodes and secrets local):
node_modules/
.env
package.json (Explicitly tells the Pi which modules to fetch):
{
"name": "glep",
"version": "3.0.0",
"main": "index.js",
"engines": {
"node": ">=22.19.0"
},
"dependencies": {
"discord.js": "^14.15.3",
"dotenv": "^16.4.5",
"quick.db": "^9.1.7"
}
}
Create a brand new Private GitHub Repository named glep, then open your MacBook Terminal inside your local project folder and execute:
# Initialize git tracking
git init -b main
# Stage and commit your clean layout
git add .
git commit -m "infrastructure: initial pristine commit"
# Link to your fresh GitHub repo (Replace with your actual account name)
git remote add origin https://github.com/YOUR_GITHUB_USERNAME/glep.git
# Force push the environment setup out
git push -u origin main --force
Connect your Raspberry Pi host directly to the GitHub ecosystem to receive secure pipeline commands.
SSH into your Raspberry Pi and install the clean automation agent binaries:
# Move to the home directory and remove old confused binary links
cd ~
rm -rf actions-runner
# Create a fresh space and pull down the ARM64 runner binaries
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-arm64-2.316.1.tar.gz -L https://github.com/actions/runner/releases/download/v2.316.1/actions-runner-linux-arm64-2.316.1.tar.gz
tar xzf ./actions-runner-linux-arm64-2.316.1.tar.gz
./config.sh string displayed under the configuration block and execute it directly on your Raspberry Pi.Enter.This attaches the pipeline engine directly to your Pi's system init files so it runs through power cycles:
# Install the service links to the system core
sudo ./svc.sh install
# Fire up the background listener agent
sudo ./svc.sh start
This workflow script maps out the automated terminal actions your Pi executes sequentially upon receiving your code modifications.
On your MacBook, open .github/workflows/deploy.yml and write this script:
name: Glep OS Automated Deployment
on:
push:
branches: [ main ] # Triggers automation on pushes to the main branch
jobs:
deploy:
name: Sync and Reload Bot
runs-on: self-hosted # Instructs execution to happen directly on your self-hosted agent
steps:
- name: Checkout Code Base
uses: actions/checkout@v4
- name: Build System Dependencies
run: |
npm install --omit=dev
- name: Hot-Reload PM2 Process
run: |
pm2 restart glep-bot --update-env || pm2 start index.js --name "glep-bot"
Save the file and push it up via your MacBook Terminal:
git add .github/workflows/deploy.yml
git commit -m "pipeline: add seamless pm2 deployment workflow"
git push origin main
With the green deployment pipeline structurally established, configure your private production keys and spin up the runtime process.
Because your bot token is rightfully hidden via git configurations, write it manually within the active workspace on your Raspberry Pi:
# Navigate directly to the new workspace directory built by the runner app
cd ~/actions-runner/_work/glep/glep
# Create the production environment variables file
nano .env
Inside the nano terminal editor, type your application secrets out cleanly:
TOKEN=YOUR_REAL_DISCORD_BOT_TOKEN_HERE
Save and close out of the screen by pressing CTRL + O, Enter, and CTRL + X.
Clear out old, cached pointers and launch your process profile fresh on Node 22:
# Erase old process memory blocks
pm2 delete glep-bot
# Fire up the bot profile with dynamic tracking enabled
pm2 start index.js --name "glep-bot" --update-env
# Lock the operational state table to survive system reboots
pm2 save
pm2 logs glep-bot --lines 20 to confirm a clean boot process. Your application will now sit proudly active and green on your Discord servers.