From 3f07637b6b8145dd317cdf72cf8676099441a0aa Mon Sep 17 00:00:00 2001 From: Mateusz Goik Date: Wed, 4 May 2022 20:22:55 +0200 Subject: [PATCH] Add firebase functions github actions --- .../workflows/firebase-functions-deploy.yml | 22 ++++++++++++++ .gitignore | 2 ++ .vscode/settings.json | 5 ++++ firebase.json | 30 +++++++++++++++++-- functions/src/index.ts | 8 ++--- 5 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/firebase-functions-deploy.yml create mode 100644 .vscode/settings.json diff --git a/.github/workflows/firebase-functions-deploy.yml b/.github/workflows/firebase-functions-deploy.yml new file mode 100644 index 0000000..b47abc1 --- /dev/null +++ b/.github/workflows/firebase-functions-deploy.yml @@ -0,0 +1,22 @@ +# Copied from https://mdabdulhalimrafi.medium.com/automate-firebase-functions-deployment-with-github-actions-ci-a0eb10fa308d + +name: Firebase function deploy +on: + push: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install npm packages + run: | + cd functions + npm install + - name: Deploy to Firebase + uses: w9jds/firebase-action@master + with: + args: deploy --only functions + env: + FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0711527..373c25d 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ testem.log # System files .DS_Store Thumbs.db + +*.log diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..dc8891d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + } +} \ No newline at end of file diff --git a/firebase.json b/firebase.json index 27f7bbd..db990c0 100644 --- a/firebase.json +++ b/firebase.json @@ -7,7 +7,8 @@ "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint", "npm --prefix \"$RESOURCE_DIR\" run build" - ] + ], + "source": "functions" }, "hosting": { "public": "dist/watering-reminder", @@ -22,5 +23,30 @@ "destination": "/index.html" } ] + }, + "emulators": { + "auth": { + "host": "127.0.0.1", + "port": 9099 + }, + "functions": { + "host": "127.0.0.1", + "port": 5001 + }, + "firestore": { + "host": "127.0.0.1", + "port": 8080 + }, + "hosting": { + "host": "127.0.0.1", + "port": 5000 + }, + "pubsub": { + "host": "127.0.0.1", + "port": 8085 + }, + "ui": { + "enabled": true + } } -} +} \ No newline at end of file diff --git a/functions/src/index.ts b/functions/src/index.ts index 10c3084..283db56 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -3,7 +3,7 @@ import * as functions from "firebase-functions"; // // Start writing Firebase Functions // // https://firebase.google.com/docs/functions/typescript // -// export const helloWorld = functions.https.onRequest((request, response) => { -// functions.logger.info("Hello logs!", {structuredData: true}); -// response.send("Hello from Firebase!"); -// }); +export const helloWorld = functions.https.onRequest((request, response) => { + functions.logger.info("Hello logs!", {structuredData: true}); + response.send("Hello from Firebase!"); +});