File tree Expand file tree Collapse file tree 5 files changed +86
-55
lines changed
Expand file tree Collapse file tree 5 files changed +86
-55
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy Server to AWS Lambda
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ paths : [ 'server/**' ]
7+ workflow_dispatch :
8+
9+ jobs :
10+ deploy :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+
17+ - name : Setup Node.js
18+ uses : actions/setup-node@v4
19+ with :
20+ node-version : ' 18'
21+ cache : ' npm'
22+ cache-dependency-path : server/package-lock.json
23+
24+ - name : Install server dependencies
25+ run : |
26+ cd server
27+ npm ci
28+
29+ - name : Deploy to AWS Lambda
30+ env :
31+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
32+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
33+ AWS_DEFAULT_REGION : ap-south-1
34+ MONGO_URI : ${{ secrets.MONGO_URI }}
35+ BASE_URL : ${{ secrets.BASE_URL }}
36+ CLIENT_URL : ${{ secrets.CLIENT_URL }}
37+ JWT_SECRET : ${{ secrets.JWT_SECRET }}
38+ EMAIL_USER : ${{ secrets.EMAIL_USER }}
39+ EMAIL_PASS : ${{ secrets.EMAIL_PASS }}
40+ GOOGLE_CLIENT_ID : ${{ secrets.GOOGLE_CLIENT_ID }}
41+ GOOGLE_CLIENT_SECRET : ${{ secrets.GOOGLE_CLIENT_SECRET }}
42+ GITHUB_CLIENT_ID : ${{ secrets.GITHUB_CLIENT_ID }}
43+ GITHUB_CLIENT_SECRET : ${{ secrets.GITHUB_CLIENT_SECRET }}
44+ RESET_TOKEN_EXPIRY : ${{ secrets.RESET_TOKEN_EXPIRY }}
45+ CLOUDINARY_CLOUD_NAME : ${{ secrets.CLOUDINARY_CLOUD_NAME }}
46+ CLOUDINARY_API_KEY : ${{ secrets.CLOUDINARY_API_KEY }}
47+ CLOUDINARY_API_SECRET : ${{ secrets.CLOUDINARY_API_SECRET }}
48+ CLOUDINARY_URL : ${{ secrets.CLOUDINARY_URL }}
49+ run : |
50+ cd server
51+ npm run deploy
Original file line number Diff line number Diff line change 44 "main" : " index.js" ,
55 "scripts" : {
66 "test" : " echo \" Error: no test specified\" && exit 1" ,
7- "start" : " nodemon server.js"
7+ "start" : " nodemon server.js" ,
8+ "deploy" : " npx serverless deploy" ,
9+ "deploy:dev" : " npx serverless deploy --stage dev" ,
10+ "deploy:prod" : " npx serverless deploy --stage prod" ,
11+ "remove" : " npx serverless remove" ,
12+ "logs" : " npx serverless logs -f app --tail" ,
13+ "offline" : " npx serverless offline"
814 },
915 "type" : " module" ,
1016 "author" : " SRKR CODING CLUB" ,
4046 "uuid" : " ^11.1.0"
4147 },
4248 "devDependencies" : {
49+ "serverless" : " ^4.21.0" ,
4350 "serverless-offline" : " ^14.4.0"
4451 }
4552}
Original file line number Diff line number Diff line change @@ -3,12 +3,11 @@ import dotenv from "dotenv"
33import connectDB from "./lib/db.js" ;
44import serverless from "serverless-http" ;
55
6- // Configuring the environment variables
76dotenv . config ( ) ;
87
98connectDB ( ) ;
109
11- const PORT = process . env . PORT || 5000
12- app . listen ( PORT , ( ) => { console . log ( `Server is running at ${ PORT } ` ) ; } )
10+ // const PORT = process.env.PORT || 5000
11+ // app.listen(PORT, () => { console.log(`Server is running at ${PORT}`); })
1312
14- // export const handler = serverless(app);
13+ export const handler = serverless ( app ) ;
You can’t perform that action at this time.
0 commit comments