https://github.com/w9jds/firebase-trigger
Github Action to update a field in a firebase database
https://github.com/w9jds/firebase-trigger
Last synced: about 14 hours ago
JSON representation
Github Action to update a field in a firebase database
- Host: GitHub
- URL: https://github.com/w9jds/firebase-trigger
- Owner: w9jds
- License: mit
- Created: 2020-03-15T09:21:02.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-09T17:45:37.000Z (over 2 years ago)
- Last Synced: 2025-05-09T02:17:28.399Z (about 14 hours ago)
- Language: TypeScript
- Size: 1.51 MB
- Stars: 15
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Firebase Trigger Github Action
This action allows you to set values into your firebase database (`realtime` or `firestore`) from and based on your current build.
I call it trigger because of what this allows you to do. Firebase has extensive tools allowing you to setup functionally that happens when you do things in your database. Weather it is a Cloud Function, Pub Sub, or just a notification on a website used by your users.
## Inputs
* `credentials` - **Required** This action uses firebase admin, so you need to provide a service account json object for proper authentication.
* `databaseUrl` - **Required** Database Url you are trying to connect to. It is usually something like: `https://[project_id].firebaseio.com`
* `databaseType` - **Optional** The database you want to connect to. Defaults to `realtime`, Accepts `realtime` and `firestore`.
* `path` - **Required** Path to the field you want to modify. If you are using firestore, this is the collection path.
* `doc` - **Required for Firestore** Document you want to modify. Uses set, so it will write/overwrite the whole file.
* `value` - **Optional** Value you would like to set. Defaults to `Date.now()` timestamp. If you are using Firestore this MUST be a JSON Object.## Usage
Writes to a realtime database, and sets the lastRelease to a `Date.now()` timestamp.
```yaml
notify:
runs-on: ubuntu-latest
name: Notify
needs: [build, deploy]
steps:
- name: Update latest version in realtime database
uses: w9jds/firebase-trigger@master
with:
credentials: ${{ secrets.FIREBASE_CREDENTIALS }}
databaseUrl: https://[project_id].firebaseio.com
path: version/lastRelease
```### Recommendation
You should store the Service Account JSON into a secret on your repo. Also, this can be very powerful if you start passing outputs from other jobs into this one to write values.