Skip to content

Commit

Permalink
continuous delivery (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazuh authored Sep 11, 2023
1 parent d9679ec commit a72bd3d
Show file tree
Hide file tree
Showing 23 changed files with 8,451 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "octo-call-c277f"
}
}
54 changes: 0 additions & 54 deletions .github/workflows/ci-cd.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
"on":
push:
branches:
- main
jobs:
cd:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_OCTO_CALL_C277F }}"
channelId: live
projectId: octo-call-c277f
38 changes: 38 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Run tests on PR
"on": pull_request
jobs:
ci:
if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Node
uses: actions/setup-node@v3
with:
node-version: 18

- name: App clean install
run: npm ci

- name: App lint
run: npm run lint

- name: App types
run: npm run types

- name: App test
run: npm test

- name: App build
run: npm run build

- name: Cloud functions clean install
run: cd functions && npm ci

- name: Cloud functions lint
run: cd functions && npm run lint

- name: Cloud functions types
run: cd functions && npm run types
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ dist-ssr

# jest coverage
coverage/

# firebase cache
.firebase/*.cache

# env vars
.env.development.local
.env.production
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ npm run test:watch

Happy coding!

## Setting up for deployment

It'll need Blaze plan active for the Firebase project. Just for testing,
its free limit should be enough even being a billable plan.

```sh
npm ci
firebase login
npm run deploy
```

It'll deploy the static client side code and bunch of serverless functions.

It needs a `.env.production` file in set too.

To achieve more stability for users in different network settings,
you'll also need to create ICE servers (STUN/TURN) using a proper CPaaS
that provides it like [Xirsys](https://global.xirsys.net/dashboard/services)
(it has a free plan for testing), [Twilio](https://www.twilio.com/docs/stun-turn)
or even [coTURN](https://github.com/coturn/coturn) (free source, but you'll
host it by yourself in your own infrastructure).

## More non-functional requirements

### Technology stack
Expand Down
32 changes: 32 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
],
"hosting": {
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
4 changes: 4 additions & 0 deletions firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"indexes": [],
"fieldOverrides": []
}
File renamed without changes.
23 changes: 23 additions & 0 deletions functions/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json", "tsconfig.dev.json"],
sourceType: "module",
},
ignorePatterns: [
"/lib/**/*", // Ignore built files.
"node_modules/",
],
plugins: ["@typescript-eslint", "import"],
rules: {
quotes: ["error", "double"],
"import/no-unresolved": 0,
indent: ["error", 2],
},
};
9 changes: 9 additions & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Compiled JavaScript files
lib/**/*.js
lib/**/*.js.map

# TypeScript v1 declaration files
typings/

# Node.js dependency directory
node_modules/
Loading

0 comments on commit a72bd3d

Please sign in to comment.