All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 57s
71 lines
3.3 KiB
YAML
71 lines
3.3 KiB
YAML
name: Deploy Beta (NATIVE)
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- beta
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: https://github.com/actions/checkout@v4
|
|
|
|
- name: Package Application
|
|
run: |
|
|
tar -czf app.tar.gz --exclude=.git --exclude=documents .
|
|
|
|
- name: Deploy to Beta EC2
|
|
run: |
|
|
if command -v apt-get >/dev/null 2>&1; then
|
|
sudo apt-get update && sudo apt-get install -y openssh-client
|
|
elif command -v apk >/dev/null 2>&1; then
|
|
apk add --no-cache openssh-client
|
|
fi
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.BETA_EC2_SSH_KEY }}" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
|
|
# Copy app archive to /tmp/
|
|
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa app.tar.gz ${{ secrets.BETA_EC2_USERNAME }}@${{ secrets.BETA_EC2_HOST }}:/tmp/
|
|
|
|
# Execute deployment commands on remote server
|
|
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa ${{ secrets.BETA_EC2_USERNAME }}@${{ secrets.BETA_EC2_HOST }} << 'EOF'
|
|
set -e
|
|
|
|
# ── Fix AWS Broken Apt Mirror ─────────────────────────────
|
|
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
|
|
sudo sed -i 's|http://ap-south-2a.clouds.ports.ubuntu.com/ubuntu-ports/|http://ports.ubuntu.com/ubuntu-ports/|g' /etc/apt/sources.list.d/ubuntu.sources
|
|
fi
|
|
|
|
# ── Install PHP 8.3 & Dependencies ────────────────────────
|
|
sudo apt-get update
|
|
sudo apt-get install -f -y
|
|
sudo apt-get install -y php8.3-cli php8.3-fpm php8.3-mysql php8.3-pgsql php8.3-gd php8.3-curl php8.3-zip php8.3-xml php8.3-mbstring php8.3-intl php8.3-soap
|
|
|
|
# ── Extract codebase to target directory ───────────────────
|
|
sudo mkdir -p /home/ubuntu/dolibarrbeta
|
|
sudo chown -R ubuntu:ubuntu /home/ubuntu/dolibarrbeta
|
|
tar -xzf /tmp/app.tar.gz -C /home/ubuntu/dolibarrbeta
|
|
sudo chmod +x /home/ubuntu
|
|
|
|
# ── Ensure conf.php exists and is writable ────────────────
|
|
mkdir -p /home/ubuntu/dolibarrbeta/htdocs/conf
|
|
if [ ! -f /home/ubuntu/dolibarrbeta/htdocs/conf/conf.php ]; then
|
|
echo '<?php' > /home/ubuntu/dolibarrbeta/htdocs/conf/conf.php
|
|
echo '// Dolibarr configuration file' >> /home/ubuntu/dolibarrbeta/htdocs/conf/conf.php
|
|
fi
|
|
chmod 666 /home/ubuntu/dolibarrbeta/htdocs/conf/conf.php
|
|
|
|
# ── Configure Nginx ─────────────────────────────────────────
|
|
sudo python3 /home/ubuntu/dolibarrbeta/dev/setup/nginx/setup_nginx.py
|
|
if [ -f /tmp/default ]; then
|
|
sudo mv /tmp/default /etc/nginx/sites-available/default
|
|
sudo nginx -t
|
|
sudo systemctl reload nginx
|
|
fi
|
|
|
|
# ── Cleanup tmp files ───────────────────────────────────────
|
|
rm -f /tmp/app.tar.gz
|
|
EOF
|