Merge branch 'main' into feat/frontend-cicd-deployment #5
Workflow file for this run
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 Kaapi to EC2 Staging | |
| on: | |
| push: | |
| branches: | |
| - feat/frontend-cicd-deployment | |
| jobs: | |
| deploy: | |
| name: Deploy Kaapi Frontend to EC2 Staging | |
| runs-on: ubuntu-latest | |
| environment: AWS_STAGING_ENV | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Deploy via SSH | |
| uses: appleboy/[email protected] | |
| env: | |
| PM2_APP_NAME: ${{ secrets.PM2_APP_NAME }} | |
| BUILD_DIRECTORY: ${{ secrets.BUILD_DIRECTORY }} | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script_stop: true | |
| script: | | |
| set -e | |
| echo "=== Navigating to Project Directory ===" | |
| cd $BUILD_DIRECTORY | |
| echo "=== Fetch Latest Code ===" | |
| git pull origin main | |
| echo "=== Stop Running Application ===" | |
| pm2 stop "$PM2_APP_NAME" || true | |
| echo "=== Install Dependencies ===" | |
| npm ci | |
| echo "=== Build Application ===" | |
| npm run build | |
| echo "=== Start Application ===" | |
| pm2 start "$PM2_APP_NAME" |