Rewrite score model in ts #96
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: Deploy to EC2 | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Deploy to EC2 | |
| env: | |
| PRIVATE_KEY: ${{ secrets.EC2_PRIVATE_KEY }} | |
| HOST: ${{ secrets.EC2_HOST }} | |
| USER: ${{ secrets.EC2_USER }} | |
| run: | | |
| echo "$PRIVATE_KEY" > github-ec2.pem && chmod 600 github-ec2.pem | |
| ssh -o StrictHostKeyChecking=no -i github-ec2.pem ${USER}@${HOST} ' | |
| set -e | |
| echo "Current directory: $(pwd)" | |
| echo "Listing home directory:" | |
| ls -la ~ | |
| REPO_URL="https://github.com/mahutt/cue.git" | |
| BRANCH="main" | |
| REPO_DIR="$HOME/github-aws-ec2" | |
| cd "$REPO_DIR" | |
| echo "Fetching latest changes..." | |
| git fetch origin | |
| git reset --hard origin/"$BRANCH" | |
| echo "Cleaning untracked files..." | |
| git clean -fd | |
| echo "Installing backend dependencies..." | |
| npm install | |
| echo "Building backend (TypeScript)..." | |
| npm run build | |
| echo "Building React frontend..." | |
| cd cue-client | |
| npm install | |
| npm run build | |
| echo "Deploying frontend to nginx directory..." | |
| sudo mkdir -p /var/www/cue-client | |
| sudo rm -rf /var/www/cue-client/* | |
| sudo cp -r dist/* /var/www/cue-client/ | |
| sudo chown -R nginx:nginx /var/www/cue-client | |
| sudo chmod -R 755 /var/www/cue-client | |
| echo "Reloading nginx to serve updated frontend..." | |
| sudo systemctl reload nginx | |
| cd .. | |
| echo "Starting/restarting cue API with PM2..." | |
| pm2 stop cue-app 2>/dev/null || true | |
| pm2 delete cue-app 2>/dev/null || true | |
| pm2 start npm --name "cue-app" -- start | |
| pm2 save | |
| echo "Application deployed successfully!" | |
| pm2 list | |
| ' |