Skip to content

Commit

Permalink
deploy: added deployment settings with cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
RukshanJS committed Jan 7, 2024
1 parent 12cdff1 commit 785a293
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 57 deletions.
4 changes: 3 additions & 1 deletion .env.dev.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Database
MONGO_URL=

# Firebase
# Auth
MOBILE_CLIENT_ID=

# JWT
JWT_SECRET=
4 changes: 3 additions & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Database
MONGO_URL=

# Firebase
# Auth
MOBILE_CLIENT_ID=

# JWT
JWT_SECRET=
4 changes: 3 additions & 1 deletion .env.prod.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Database
MONGO_URL=

# Firebase
# Auth
MOBILE_CLIENT_ID=

# JWT
JWT_SECRET=
27 changes: 27 additions & 0 deletions .github/workflows/firebase-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy NestJS API to Firebase

on:
push:
branches:
- main
- dev

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '16'
- name: Install dependencies.
run: npm install
- name: Set correct firebase project based on git branch.
run: echo "FIREBASE_PROJECT=$(if [ ${{ github.ref }} == 'refs/heads/main' ]; then echo 'prod'; else echo 'dev'; fi)" >> $GITHUB_ENV
- name: Deploy to firebase cloud functions.
uses: w9jds/firebase-action@master
with:
args: deploy --only functions --project ${{ env.FIREBASE_PROJECT }}
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
20 changes: 0 additions & 20 deletions .github/workflows/firebase-hosting-merge.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/firebase-hosting-pull-request.yml

This file was deleted.

16 changes: 1 addition & 15 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,5 @@
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
],
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"deploy:dev": "firebase deploy --only functions --project dev",
"deploy:prod": "firebase deploy --only functions --project prod",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import * as functions from 'firebase-functions';

const server = express();

// This is for prod.

export const createNestServer = async (expressInstance) => {
const app = await NestFactory.create(
AppModule,
Expand Down

0 comments on commit 785a293

Please sign in to comment.