Update main.yml #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Teramont Docs | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts | |
- name: Sync files to server | |
run: rsync -avz --exclude 'node_modules' --exclude '.git' ./ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:/var/www/teramont-docs | |
- name: Build on Server | |
run: | | |
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} << 'EOF' | |
export PATH=$PATH:/root/.nvm/versions/node/v18.19.0/bin | |
cd /var/www/teramont-docs | |
echo "🔧 Setting up Node.js..." | |
nvm use v18.19.0 | |
echo "📦 Installing dependencies..." | |
npm install --legacy-peer-deps | |
echo "🧪 Testing build..." | |
if npm run build; then | |
echo "✅ Build successful! Deploying..." | |
echo "🚀 Deployment complete!" | |
else | |
echo "❌ Build failed! Aborting deployment." | |
exit 1 | |
fi | |
EOF |