Skip to content

Commit ed335e3

Browse files
committed
Add CI/CD pipeline to ios backend
1 parent 7f815ed commit ed335e3

File tree

3 files changed

+2732
-37
lines changed

3 files changed

+2732
-37
lines changed

.github/workflows/aws.yml

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy Next.js to EC2
1+
name: Deploy Express.js to EC2
22

33
on:
44
push:
@@ -58,11 +58,11 @@ jobs:
5858
[ -f ~/.profile ] && source ~/.profile
5959
6060
# Set deployment variables
61-
APP_DIR="/home/ubuntu/smar/smar-ios-backend"
61+
APP_DIR="/home/ubuntu/smar/SMAR-ios-backend"
6262
# BACKUP_DIR="/var/backups/jeshwinprince-$(date +%Y%m%d-%H%M%S)"
6363
6464
#! TODO: Replace with actual path to env file
65-
ENV_DIR="/var/www/config/jeshwinprince"
65+
ENV_DIR="/var/www/config/smar"
6666
ENV_FILE="$ENV_DIR/.env.production"
6767
6868
# Check if Node.js and npm are available
@@ -124,47 +124,15 @@ jobs:
124124
echo "Installing dependencies..."
125125
npm ci --omit=dev
126126
127-
# Build the Next.js application on EC2
128-
echo "Building Next.js application..."
129-
NODE_ENV=production npm run build
130-
131127
# Set proper permissions
132128
sudo chown -R $USER:$USER $APP_DIR
133129
134130
# Start the application with PM2
135-
pm2 start npm --name "SAR-backend" -- start
131+
pm2 start index.js --name "SMAR-ios-backend"
136132
pm2 save
137133
138134
# Ensure PM2 starts on boot
139135
pm2 startup || true
140136
141137
echo "Deployment completed successfully"
142138
echo "Environment file location: $ENV_FILE"
143-
144-
- name: Health check
145-
uses: appleboy/[email protected]
146-
with:
147-
host: ${{ secrets.TEST_HOST }}
148-
username: ${{ secrets.TEST_USERNAME }}
149-
key: ${{ secrets.TEST_SSH_KEY }}
150-
port: ${{ secrets.TEST_SSH_PORT || 22 }}
151-
script: |
152-
# Wait for application to start
153-
sleep 10
154-
155-
# Check if application is running
156-
if pm2 list | grep -q "SAR-backend.*online"; then
157-
echo "✅ Application is running successfully"
158-
159-
# Optional: Test HTTP endpoint
160-
if curl -f http://localhost:5002 > /dev/null 2>&1; then
161-
echo "✅ Application health check passed"
162-
else
163-
echo "⚠️ Application started but health check failed"
164-
exit 1
165-
fi
166-
else
167-
echo "❌ Application failed to start"
168-
pm2 logs "SAR-backend" --lines 20
169-
exit 1
170-
fi

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ build
33
.nyc
44
.DS_Store
55
search_results.csv
6-
package-lock.json
6+
# package-lock.json
77

88
# Logs
99
logs

0 commit comments

Comments
 (0)