From c79cf5320045a07b79a01a74aae02797d066341b Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Wed, 26 Jun 2024 22:26:44 +0100 Subject: [PATCH] [+] Firebase support --- .firebaserc | 5 ++ .github/workflows/firebase-hosting-merge.yml | 20 +++++ .../firebase-hosting-pull-request.yml | 21 +++++ firebase.json | 20 +++++ firestore.indexes.json | 16 ++++ firestore.rules | 8 ++ public/index.html | 89 +++++++++++++++++++ 7 files changed, 179 insertions(+) create mode 100644 .firebaserc create mode 100644 .github/workflows/firebase-hosting-merge.yml create mode 100644 .github/workflows/firebase-hosting-pull-request.yml create mode 100644 firebase.json create mode 100644 firestore.indexes.json create mode 100644 firestore.rules create mode 100644 public/index.html diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..0a6e3a5 --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "servi-e6705" + } +} diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..277763b --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,20 @@ +# 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: + - master +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm ci && npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SERVI_E6705 }} + channelId: live + projectId: servi-e6705 diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..fb2f8fb --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -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 PR +on: pull_request +permissions: + checks: write + contents: read + pull-requests: write +jobs: + build_and_preview: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm ci && npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SERVI_E6705 }} + projectId: servi-e6705 diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..4335fd1 --- /dev/null +++ b/firebase.json @@ -0,0 +1,20 @@ +{ + "firestore": { + "rules": "firestore.rules", + "indexes": "firestore.indexes.json" + }, + "hosting": { + "public": "public", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} diff --git a/firestore.indexes.json b/firestore.indexes.json new file mode 100644 index 0000000..d8b540b --- /dev/null +++ b/firestore.indexes.json @@ -0,0 +1,16 @@ +{ + "indexes": [], + "fieldOverrides": [ + { + "collectionGroup": "servers", + "fieldPath": "port", + "ttl": false, + "indexes": [ + { + "order": "DESCENDING", + "queryScope": "COLLECTION_GROUP" + } + ] + } + ] +} diff --git a/firestore.rules b/firestore.rules new file mode 100644 index 0000000..e4e1e50 --- /dev/null +++ b/firestore.rules @@ -0,0 +1,8 @@ +rules_version = '2'; +service cloud.firestore { + match /databases/{database}/documents { + match /users/{userId} { + allow read: if request.auth!= null && request.auth.uid == userId; + } + } +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..3bfb423 --- /dev/null +++ b/public/index.html @@ -0,0 +1,89 @@ + + + + + + Welcome to Firebase Hosting + + + + + + + + + + + + + + + + + + + +
+

Welcome

+

Firebase Hosting Setup Complete

+

You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!

+ Open Hosting Documentation +
+

Firebase SDK Loading…

+ + + +