Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14-slim
FROM node:current-slim
RUN npm install -g firebase-tools
COPY entrypoint.sh /usr/local/bin
ENTRYPOINT ["entrypoint.sh"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build:
docker build . -t jsryudev/deploy-firebase-functions
docker build . -t dayzero-eng/deploy-firebase-functions
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Deploy to Firebase Functions for Node14
# Deploy to Firebase for Node18

A GitHub Action to deploy to Firebase Cloud Functions for Node14.
A GitHub Action to deploy to Firebase for Node18.

- Make sure that you checkout the repository using the [actions/checkout](https://github.com/actions/checkout) action
- Make sure that you have the `firebase.json` file in the repository
- To obtain the Firebase token, run `firebase login:ci` on your local computer and [store the token](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) as the `FIREBASE_TOKEN` secret
- To obtain service account credentials, get the service account JSON file from Firebase console and set its path to `GOOGLE_APPLICATION_CREDENTIALS`
- Either `FIREBASE_TOKEN` or `GOOGLE_APPLICATION_CREDENTIALS` are required to deploy the project. No need to set both at the same time.
- Specify the Firebase project name in the `FIREBASE_PROJECT` env var

## Workflow examples
Expand All @@ -23,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jsryudev/[email protected].2
- uses: dayzero-eng/[email protected].5
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_PROJECT: firebase-project-id
Expand All @@ -43,7 +45,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jsryudev/[email protected].2
- uses: dayzero-eng/[email protected].5
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_PROJECT: firebase-project-id
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Deploy to Firebase Cloud Functions'
author: 'jsryudev <[email protected]>'
description: 'A GitHub Action to deploy to Firebase Cloud Functions'
name: 'Deploy to Firebase'
author: 'dayzero-eng'
description: 'A GitHub Action to deploy to Firebase'
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
11 changes: 8 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash

npm install

cd functions; npm install

if [ -z "${FIREBASE_TOKEN}" ]; then
echo "FIREBASE_TOKEN is missing"
if [[ -z "${FIREBASE_TOKEN}" && -z "${GOOGLE_APPLICATION_CREDENTIALS}" ]]; then
echo "Access tokens are missing! Provide either FIREBASE_TOKEN or GOOGLE_APPLICATION_CREDENTIALS"
exit 1
fi

Expand All @@ -12,7 +14,10 @@ if [ -z "${FIREBASE_PROJECT}" ]; then
exit 1
fi

cd ..

firebase experiments:enable webframeworks

firebase deploy \
-m "${GITHUB_REF} (${GITHUB_SHA})" \
--project ${FIREBASE_PROJECT} \
--only functions