Merge branch 'main' of https://github.com/Team-Wego/SeolStudy-FE #8
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: [ main ] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| - name: Install & Build | |
| run: | | |
| npm install | |
| npm run build | |
| - name: Verify build output | |
| run: | | |
| echo "=== .env.production ===" | |
| cat .env.production | |
| echo "=== Checking API URL in build ===" | |
| grep -r "localhost:8080" dist/ || echo "OK: no localhost:8080 found" | |
| grep -r "/api" dist/assets/*.js | head -3 || echo "WARNING: /api not found" | |
| - name: Clean old files and deploy | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_KEY }} | |
| script: | | |
| rm -rf /home/ec2-user/frontend/dist/* | |
| rm -rf /home/ec2-user/frontend/assets /home/ec2-user/frontend/index.html | |
| - name: Copy Dist to EC2 | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_KEY }} | |
| source: "dist/*" | |
| target: "/home/ec2-user/frontend" | |
| - name: Verify deployment | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_KEY }} | |
| script: | | |
| echo "=== Files in frontend ===" | |
| ls -la /home/ec2-user/frontend/ | |
| ls -la /home/ec2-user/frontend/dist/ 2>/dev/null || echo "No dist/ subfolder" | |
| echo "=== Checking for localhost in JS ===" | |
| grep -r "localhost:8080" /home/ec2-user/frontend/ 2>/dev/null || echo "OK: clean" |