ci: add pipeline #3
This file contains hidden or 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: Frontend Deploy | ||
on: | ||
push: | ||
branches: | ||
- setup | ||
- main | ||
jobs: | ||
deploy: | ||
Check failure on line 10 in .github/workflows/frontend-cd.yml
|
||
runs-on: ubuntu-latest | ||
needs: [test-and-build] | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Upload Build Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: next-build | ||
path: .next | ||
if-no-files-found: error | ||
include-hidden-files: true | ||
compression-level: 6 | ||
overwrite: false | ||
- name: Install sshpass | ||
run: sudo apt-get install -y sshpass | ||
- name: Deploy to Production Server | ||
run: | | ||
echo "🚀 Deploying .next build to server..." | ||
sshpass -p "${{ secrets.SERVER_PASSWORD }}" scp -o StrictHostKeyChecking=no -r .next package.json pnpm-lock.yaml \ | ||
"${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:/home/${{ secrets.SERVER_USER }}/AI-Ad-Gen-Frontend" | ||
- name: Start Application on Server | ||
run: | | ||
sshpass -p "${{ secrets.SERVER_PASSWORD }}" ssh -o StrictHostKeyChecking=no \ | ||
"${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}" << 'EOF' | ||
set -e # Stop script on error | ||
cd /home/${{ secrets.SERVER_USER }}/AI-Ad-Gen-Frontend | ||
pnpm install --frozen-lockfile | ||
pm2 delete ai-adgen-frontend || true | ||
pm2 start pnpm --name ai-adgen-frontend -- start | ||
EOF |