All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 43s
77 lines
3.5 KiB
YAML
77 lines
3.5 KiB
YAML
name: Deploy Beta (NATIVE)
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- beta
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: node:20-alpine
|
|
steps:
|
|
- name: Install git
|
|
run: apk add --no-cache git
|
|
|
|
- name: Checkout Code
|
|
uses: https://github.com/actions/checkout@v4
|
|
|
|
- name: Package Application
|
|
run: |
|
|
tar -czf app.tar.gz --exclude=.git --exclude=node_modules --exclude=data --exclude=tmp .
|
|
|
|
- name: Deploy to cisystem EC2
|
|
run: |
|
|
apk add --no-cache openssh-client
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.BETA_EC2_SSH_KEY }}" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
|
|
# Copy app archive and systemd service
|
|
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa app.tar.gz resourcemanagement.service ${{ secrets.BETA_EC2_USERNAME }}@${{ secrets.BETA_EC2_HOST }}:/tmp/
|
|
|
|
# Execute deployment commands on cisystem
|
|
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa ${{ secrets.BETA_EC2_USERNAME }}@${{ secrets.BETA_EC2_HOST }} << 'EOF'
|
|
set -e
|
|
|
|
# ── 1. Target Directory Setup ────────────────────────────────
|
|
sudo mkdir -p /home/ubuntu/resourcemanagement/logs
|
|
sudo chown -R ubuntu:ubuntu /home/ubuntu/resourcemanagement
|
|
tar -xzf /tmp/app.tar.gz -C /home/ubuntu/resourcemanagement
|
|
|
|
cd /home/ubuntu/resourcemanagement
|
|
|
|
# ── 2. Environment Configuration ────────────────────────────
|
|
printf "NODE_ENV=production\nPORT=3002\nUPTIME_KUMA_PORT=3002\nUPTIME_KUMA_DB_TYPE=postgres\nDB_HOST=127.0.0.1\nDB_PORT=5432\nDB_USER=vignesh\nDB_PASSWORD=vignesh_secret_pass_2026\nDB_NAME=ResourceManagement\n" > .env
|
|
|
|
# ── 3. Install Dependencies & Build ─────────────────────────
|
|
npm install --legacy-peer-deps --engine-strict=false
|
|
npm run build
|
|
|
|
# ── 4. Systemd Service Deployment ───────────────────────────
|
|
sudo cp /tmp/resourcemanagement.service /etc/systemd/system/resourcemanagement.service
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable resourcemanagement.service
|
|
sudo systemctl restart resourcemanagement.service || {
|
|
echo "resourcemanagement.service failed to restart! Logs:"
|
|
sudo journalctl -u resourcemanagement.service -n 50 --no-pager
|
|
exit 1
|
|
}
|
|
|
|
echo "=== Diagnostic: Active Listening Ports ==="
|
|
sudo ss -tulpn | grep -E "3000|3001|3002|node" || true
|
|
echo "=== Diagnostic: Nginx Configuration for status.tradhox.com ==="
|
|
sudo grep -rn "status.tradhox.com" /etc/nginx/ -A 20 || true
|
|
echo "=== Diagnostic: Systemd Services Status ==="
|
|
sudo systemctl is-active resourcemanagement.service || true
|
|
sudo systemctl is-active uptime-kuma.service || true
|
|
echo "=== Diagnostic: PM2 status ==="
|
|
pm2 list || which pm2 || true
|
|
|
|
# ── 5. Reload Nginx ─────────────────────────────────────────
|
|
sudo nginx -t && sudo systemctl reload nginx
|
|
|
|
rm -f /tmp/app.tar.gz /tmp/resourcemanagement.service
|
|
echo "ResourceManagement deployed successfully to status.tradhox.com!"
|
|
EOF
|