Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
siarheidudko committed Dec 29, 2023
0 parents commit e350f86
Show file tree
Hide file tree
Showing 14 changed files with 566 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
root = true

[*]
indent_style = space
indent_size = 2

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[{package,bower}.json]
indent_style = space
indent_size = 2

[{.eslintrc,.scss-lint.yml}]
indent_style = space
indent_size = 2

[*.{scss,sass}]
indent_style = space
indent_size = 2
40 changes: 40 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"projects": {
"production": "fir-template-40a59",
"staging": "fir-template-staging",
"development": "fir-template-development",
"default": "fir-template-40a59"
},
"targets": {
"fir-template-development": {
"hosting": {
"website": [
"fir-template-website-development"
],
"api": [
"fir-template-api-development"
]
}
},
"fir-template-staging": {
"hosting": {
"website": [
"fir-template-website-staging"
],
"api": [
"fir-template-api-staging"
]
}
},
"fir-template-40a59": {
"hosting": {
"website": [
"fir-template-website"
],
"api": [
"fir-template-api"
]
}
}
}
}
79 changes: 79 additions & 0 deletions .github/workflows/deploy-development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Deploy Database, Storage, Firestore
on:
push:
branches:
- dev
env:
NODE_VERSION: 20
TOKEN_FOR_WORKFLOW: ${{ secrets.TOKEN_FOR_WORKFLOW }}
FIREBASE_PROJECT: "development"
GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/firebase/functions/accounts/development.json
BRANCH: "dev"
FIREBASE_CHILD_REPO: "dudko-dev/firebase-template-functions"
FIREBASE_CHILD_BRANCH: "dev"
jobs:
deploy:
name: Deploy Database, Storage, Firestore
runs-on: ubuntu-latest
env:
ENVKEY: ${{ secrets.ENVKEY }}
timeout-minutes: 10
steps:
- name: Сheckout firebase repo (${{ github.repository }})
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}
path: "firebase"
- name: Сheckout firebase functions repo (${{ env.FIREBASE_CHILD_REPO }})
uses: actions/checkout@v4
with:
repository: ${{ env.FIREBASE_CHILD_REPO }}
ref: refs/heads/${{ env.FIREBASE_CHILD_BRANCH }}
token: ${{ env.TOKEN_FOR_WORKFLOW }}
path: "firebase/functions"
- name: Change mode directory
run: chmod 0766 -R firebase
working-directory: ${{ github.workspace }}
- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install deploy dependencies
run: sudo npm install firebase-tools -g
working-directory: ${{ github.workspace }}/firebase
- name: Export envkey to file
run: echo "$ENVKEY">./.envkey
working-directory: ${{ github.workspace }}/firebase/functions
- name: Decrypt env and accounts files
run: npm run decrypt
working-directory: ${{ github.workspace }}/firebase/functions
- name: Select firebase project
run: firebase use $FIREBASE_PROJECT
working-directory: ${{ github.workspace }}/firebase
- name: Deploy to firebase
run: firebase deploy -m "Autodeploy from GitHUB ($GITHUB_ACTOR)" --only database,storage,firestore
working-directory: ${{ github.workspace }}/firebase
- name: The job has failed - archive result
if: ${{ failure() }}
run: |
if [[ -d ${{ github.workspace }}/firebase ]]; then
tar -czf firebase.tar.gz firebase;
fi
working-directory: ${{ github.workspace }}
- name: The job has failed - archive npm logs
if: ${{ failure() }}
run: |
if [[ -d /home/runner/.npm/_logs ]]; then
tar -czf ${{ github.workspace }}/npm-logs.tar.gz /home/runner/.npm/_logs;
fi
working-directory: /
- name: The job has failed - upload artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.FIREBASE_PROJECT }}-firebase-debug
path: |
${{ github.workspace }}/firebase.tar.gz
${{ github.workspace }}/npm-logs.tar.gz
retention-days: 1
79 changes: 79 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Deploy Database, Storage, Firestore
on:
push:
branches:
- main
env:
NODE_VERSION: 20
TOKEN_FOR_WORKFLOW: ${{ secrets.TOKEN_FOR_WORKFLOW }}
FIREBASE_PROJECT: "production"
GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/firebase/functions/accounts/production.json
BRANCH: "main"
FIREBASE_CHILD_REPO: "dudko-dev/firebase-template-functions"
FIREBASE_CHILD_BRANCH: "main"
jobs:
deploy:
name: Deploy Database, Storage, Firestore
runs-on: ubuntu-latest
env:
ENVKEY: ${{ secrets.ENVKEY }}
timeout-minutes: 10
steps:
- name: Сheckout firebase repo (${{ github.repository }})
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}
path: "firebase"
- name: Сheckout firebase functions repo (${{ env.FIREBASE_CHILD_REPO }})
uses: actions/checkout@v4
with:
repository: ${{ env.FIREBASE_CHILD_REPO }}
ref: refs/heads/${{ env.FIREBASE_CHILD_BRANCH }}
token: ${{ env.TOKEN_FOR_WORKFLOW }}
path: "firebase/functions"
- name: Change mode directory
run: chmod 0766 -R firebase
working-directory: ${{ github.workspace }}
- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install deploy dependencies
run: sudo npm install firebase-tools -g
working-directory: ${{ github.workspace }}/firebase
- name: Export envkey to file
run: echo "$ENVKEY">./.envkey
working-directory: ${{ github.workspace }}/firebase/functions
- name: Decrypt env and accounts files
run: npm run decrypt
working-directory: ${{ github.workspace }}/firebase/functions
- name: Select firebase project
run: firebase use $FIREBASE_PROJECT
working-directory: ${{ github.workspace }}/firebase
- name: Deploy to firebase
run: firebase deploy -m "Autodeploy from GitHUB ($GITHUB_ACTOR)" --only database,storage,firestore
working-directory: ${{ github.workspace }}/firebase
- name: The job has failed - archive result
if: ${{ failure() }}
run: |
if [[ -d ${{ github.workspace }}/firebase ]]; then
tar -czf firebase.tar.gz firebase;
fi
working-directory: ${{ github.workspace }}
- name: The job has failed - archive npm logs
if: ${{ failure() }}
run: |
if [[ -d /home/runner/.npm/_logs ]]; then
tar -czf ${{ github.workspace }}/npm-logs.tar.gz /home/runner/.npm/_logs;
fi
working-directory: /
- name: The job has failed - upload artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.FIREBASE_PROJECT }}-firebase-debug
path: |
${{ github.workspace }}/firebase.tar.gz
${{ github.workspace }}/npm-logs.tar.gz
retention-days: 1
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
.firebase
/functions/
/hosting/website/
/hosting/api/
*.log
36 changes: 36 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.formatOnSave": true,
"[json]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": "full",
"editor.folding": true,
"editor.renderWhitespace": "all"
},
"[javascript]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": "full",
"editor.folding": true,
"editor.renderWhitespace": "all"
},
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "typescript",
"autoFix": true
},
{
"language": "typescriptreact",
"autoFix": true
}
],
"files.associations": {
"*.json": "jsonc"
}
}
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Firebase Template

This is part of the [firebase-template project](!https://github.com/search?q=topic%3Afirebase-template+org%3Adudko-dev&type=Repositories), which consists of:

- `firebase` - firebase settings, including hosting settings and basic access rights, repo: [dudko-dev/firebase-template](https://github.com/dudko-dev/firebase-template)
- `firebase/functions` - gRPC and http cloud functions, repo: [dudko-dev/firebase-template-functions](https://github.com/dudko-dev/firebase-template-functions)
- `firebase/hosting/api` - a web portal based on react, repo: [dudko-dev/firebase-template-website](https://github.com/dudko-dev/firebase-template-website)
- `firebase/hosting/website` - web portal on js, repo: [dudko-dev/firebase-template-api](https://github.com/dudko-dev/firebase-template-api)

The project allows you to quickly deploy the basic configuration of firebase, configure the basic skeleton of cloud functions, deploy a portal on react with ready-made authorization/registration/email confirmation/password recovery methods.

just run a script:

```bash
#!/usr/bin/bash
FIREBASE_REPO="dudko-dev/firebase-template"
FIREBASE_REPO_DIR="."
FIREBASE_FUNCTIONS_REPO="dudko-dev/firebase-template-functions"
FIREBASE_FUNCTIONS_DIR="./functions"
FIREBASE_WEBSITE_REPO="dudko-dev/firebase-template-website"
FIREBASE_WEBSITE_DIR="./hosting/website"
FIREBASE_WEBAPI_REPO="dudko-dev/firebase-template-api"
FIREBASE_WEBAPI_DIR="./hosting/api"

mkdir $FIREBASE_REPO_DIR
git clone $FIREBASE_REPO $FIREBASE_REPO_DIR
mkdir $FIREBASE_FUNCTIONS_DIR
git clone $FIREBASE_FUNCTIONS_REPO $FIREBASE_FUNCTIONS_DIR
mkdir $FIREBASE_WEBSITE_DIR
git clone $FIREBASE_WEBSITE_REPO $FIREBASE_WEBSITE_DIR
mkdir $FIREBASE_WEBAPI_DIR
git clone $FIREBASE_WEBAPI_REPO $FIREBASE_WEBAPI_DIR
```
12 changes: 12 additions & 0 deletions database.rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"rules": {
".read": false,
".write": false,
"users": {
"$user_id": {
".read": "$user_id === auth.uid",
".write": false
}
}
}
}
Loading

0 comments on commit e350f86

Please sign in to comment.