Skip to content

Update deployment scripts with custom SSH port and user config #5

Update deployment scripts with custom SSH port and user config

Update deployment scripts with custom SSH port and user config #5

Workflow file for this run

name: Deploy to Production
on:
push:
branches:
- master
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add server to known hosts
run: |
mkdir -p ~/.ssh
# Try with verbose output to see what's happening
echo "Running ssh-keyscan with verbose output and custom port..."
ssh-keyscan -v -p 2048 -H 104.36.23.197 >> ~/.ssh/known_hosts || true
# If the above fails, create a known_hosts file manually
echo "Creating known_hosts file manually as fallback..."
echo "${{ secrets.SERVER_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
# Create SSH config file with custom port and user
echo "Creating SSH config file..."
cat > ~/.ssh/config << EOF
Host profullstack.com
HostName 104.36.23.197
User ubuntu
Port 2048
EOF
chmod 600 ~/.ssh/config
# Verify the files exist and have content
ls -la ~/.ssh/
echo "Content of SSH config:"
cat ~/.ssh/config
echo "Lines in known_hosts:"
wc -l ~/.ssh/known_hosts || true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y rsync
- name: Create .env file from secret
run: |
# Create .env file from GitHub secret
echo "${{ secrets.ENV_FILE_CONTENT }}" > .env
# Print confirmation (without showing the content for security)
echo "Created .env file with $(grep -c '' .env) lines"
- name: Deploy to server
run: |
# Make deploy script executable
chmod +x ./bin/deploy.sh
# Print debug info
echo "Current directory: $(pwd)"
echo "Files in bin directory:"
ls -la ./bin
# Run deploy script with IP address, port, and user
DEPLOY_REMOTE_HOST=104.36.23.197 DEPLOY_REMOTE_PORT=2048 DEPLOY_REMOTE_USER=ubuntu ./bin/deploy.sh
# Run test script to verify deployment
echo "Running test script on remote server..."
ssh -p 2048 [email protected] "cd $DEPLOY_REMOTE_DIR && chmod +x bin/test-github-actions.sh && ./bin/test-github-actions.sh"
env:
DEPLOY_REMOTE_HOST: 104.36.23.197
DEPLOY_REMOTE_PORT: 2048
DEPLOY_REMOTE_USER: ubuntu
DEPLOY_REMOTE_DIR: www/profullstack.com/pdf
INSTALL_SERVICE: true