diff --git a/Dockerfile b/Dockerfile index 7532a3ea..6ebbb7fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/Makefile b/Makefile index 3c565327..ecb4c287 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ build: - docker build . -t jsryudev/deploy-firebase-functions + docker build . -t dayzero-eng/deploy-firebase-functions diff --git a/README.md b/README.md index f1f79932..49f7ee88 100644 --- a/README.md +++ b/README.md @@ -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 @@ -23,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: jsryudev/deploy-firebase-functions@v0.0.2 + - uses: dayzero-eng/deploy-firebase-functions@v0.0.5 env: FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} FIREBASE_PROJECT: firebase-project-id @@ -43,7 +45,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: jsryudev/deploy-firebase-functions@v0.0.2 + - uses: dayzero-eng/deploy-firebase-functions@v0.0.5 env: FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} FIREBASE_PROJECT: firebase-project-id diff --git a/action.yml b/action.yml index 1e60e5cf..e62073f9 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,6 @@ -name: 'Deploy to Firebase Cloud Functions' -author: 'jsryudev ' -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' diff --git a/entrypoint.sh b/entrypoint.sh index 32bdfeb9..b3540b96 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 @@ -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