Run firebase emulators on github actions - firebase

I'm trying to run my test on Github Actinos but after several attempts I was not able to do so.
Receiving
Error: firestore: Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/
- name: Test
uses: w9jds/firebase-action#v1.3.1
env:
JAVA_HOME: ${{ env.JAVA_HOME }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
GCLOUD_PROJECT: ${{ secrets.nextGCLOUD_PROJECT }}
PROJECT_ID: ${{ secrets.nextFIREBASE_PROJECTID }}
with:
args: |
setup:emulators:firestore --debug
firebase emulators:exec --debug --only functions,firestore \"npm run test --exit -- --forceExit --detectOpenHandles\"
- name: Print debug logs
if: failure()
run: |
java --version
ls -la
find . -type f -name "fire*-debug.log" | xargs cat
That's the output from action name: Test
/usr/bin/docker run --name d38e5ad93a422d456db01475acdae41155_521526 --label 3888d3 --workdir /github/workspace --rm -e JAVA_HOME -e FIREBASE_TOKEN -e GCLOUD_PROJECT -e PROJECT_ID -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true --network github_network_2107949b3a2c43d499d641b1c2f0fd12 -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/pwa/pwa":"/github/workspace" 3888d3:8e5ad93a422d456db01475acdae41155 setup:emulators:firestore --debug
firebase emulators:exec --debug --only functions,firestore \"npm run test --exit -- --forceExit --detectOpenHandles\"
setting firebase project to ***
Now using project ***
i firestore: downloading cloud-firestore-emulator-v1.11.4.jar... {"metadata":{"emulator":{"name":"firestore"},"message":"downloading cloud-firestore-emulator-v1.11.4.jar..."}}
[2020-06-06T12:59:30.184Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-06-06T12:59:30.186Z] > authorizing via FIREBASE_TOKEN environment variable
i emulators: Starting emulators: functions, firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore"}}
[2020-06-06T12:59:30.217Z] [hub] writing locator at /tmp/hub-***.json
✔ functions: Using node#10 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node#10 from host."}}
[2020-06-06T12:59:30.249Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[2020-06-06T12:59:30.249Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2020-06-06T12:59:30.249Z] Starting Firestore Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/github/home/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar","--host","localhost","--port",8080,"--rules","/github/workspace/firestore.rules","--functions_emulator","localhost:5001"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/github/home/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar\",\"--host\",\"localhost\",\"--port\",8080,\"--rules\",\"/github/workspace/firestore.rules\",\"--functions_emulator\",\"localhost:5001\"],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"functions_emulator\",\"seed_from_export\"],\"joinArgs\":false}"}}
i firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
Error: firestore: Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/
That's the output from action name: Print debug logs
[debug] [2020-06-06T12:59:27.289Z] ----------------------------------------------------------------------
[debug] [2020-06-06T12:59:27.291Z] Command: /usr/local/bin/node /usr/local/bin/firebase setup:emulators:firestore --debug
[debug] [2020-06-06T12:59:27.292Z] CLI Version: 8.4.2
[debug] [2020-06-06T12:59:27.292Z] Platform: linux
[debug] [2020-06-06T12:59:27.292Z] Node Version: v10.21.0
[debug] [2020-06-06T12:59:27.292Z] Time: Sat Jun 06 2020 12:59:27 GMT+0000 (Coordinated Universal Time)
[debug] [2020-06-06T12:59:27.293Z] ----------------------------------------------------------------------
[debug] [2020-06-06T12:59:27.293Z]
[info] i firestore: downloading cloud-firestore-emulator-v1.11.4.jar... {"metadata":{"emulator":{"name":"firestore"},"message":"downloading cloud-firestore-emulator-v1.11.4.jar..."}}
[debug] [2020-06-06T12:59:30.168Z] ----------------------------------------------------------------------
[debug] [2020-06-06T12:59:30.170Z] Command: /usr/local/bin/node /usr/local/bin/firebase emulators:exec --debug --only functions,firestore npm run test --exit -- --forceExit --detectOpenHandles
[debug] [2020-06-06T12:59:30.171Z] CLI Version: 8.4.2
[debug] [2020-06-06T12:59:30.171Z] Platform: linux
[debug] [2020-06-06T12:59:30.171Z] Node Version: v10.21.0
[debug] [2020-06-06T12:59:30.171Z] Time: Sat Jun 06 2020 12:59:30 GMT+0000 (Coordinated Universal Time)
[debug] [2020-06-06T12:59:30.171Z] ----------------------------------------------------------------------
[debug] [2020-06-06T12:59:30.171Z]
[debug] [2020-06-06T12:59:30.184Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2020-06-06T12:59:30.186Z] > authorizing via FIREBASE_TOKEN environment variable
[info] i emulators: Starting emulators: functions, firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore"}}
[debug] [2020-06-06T12:59:30.217Z] [hub] writing locator at /tmp/hub-***.json
[info] ✔ functions: Using node#10 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node#10 from host."}}
[debug] [2020-06-06T12:59:30.249Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[debug] [2020-06-06T12:59:30.249Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[debug] [2020-06-06T12:59:30.249Z] Starting Firestore Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/github/home/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar","--host","localhost","--port",8080,"--rules","/github/workspace/firestore.rules","--functions_emulator","localhost:5001"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/github/home/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar\",\"--host\",\"localhost\",\"--port\",8080,\"--rules\",\"/github/workspace/firestore.rules\",\"--functions_emulator\",\"localhost:5001\"],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"functions_emulator\",\"seed_from_export\"],\"joinArgs\":false}"}}
[info] i firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[error]
[error] Error: firestore: Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/
How can I run my tests on Github Actions?

At the time of writing, the unofficial firebase-action has recently added Java support. Unfortunately this is Java 7, and the emulator requires Java 8. (I have opened an issue in the repo to get this fixed).
Alternatively, for anyone that is interested, I have found the following to work well:
name: Test Firebase rules on PR
'on': pull_request
jobs:
test_rules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: '12'
- run: npm install -g firebase-tools
- run: npm ci
- run: firebase emulators:exec --only firestore \"npm run test --exit\"
There are two important notes about the above workflow file:
ubuntu-latest is required as this contains both node and java.
actions/setup-node#v1 is required to setup node to allow the install of global npm packages.
Also, if you would like to add a deploy step to the above you would only need to add this above the setup-node step, for authentication:
- uses: google-github-actions/setup-gcloud#master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
(This is because the export_default_credentials will export the GOOGLE_APPLICATION_CREDENTIALS environment variable which firebase-tools will use for authentication).

Try this -
name: next
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setting-up Node.js
uses: actions/setup-node#v2-beta
with:
node-version: '10'
- name: Installing npm dependencies
run: npm ci --prefer-offline --no-audit --progress=false
- name: Checking-out
uses: actions/checkout#v2
- name: Setting-up JAVA
uses: actions/setup-java#v1.3.0
with:
java-version: "12.x"
- name: Setup and Test Emulator
uses: w9jds/firebase-action#v1.3.1
env:
JAVA_HOME: ${{ env.JAVA_HOME }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
GCLOUD_PROJECT: ${{ secrets.nextGCLOUD_PROJECT }}
PROJECT_ID: ${{ secrets.nextFIREBASE_PROJECTID }}
with:
args: |
setup:emulators:firestore
emulators:exec --only firestore \"npm run test --exit\"

This worked for me
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: '12'
- name: Install Dependacies
run: cd functions && npm install
- name: Test to Firebase
uses: w9jds/firebase-action#master
with:
args: emulators:exec --only firestore \"cd functions && npm run test --exit\"
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

If you don't need node environment, try this
name: Test and coverage
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
with:
fetch-depth: 2
- uses: actions/setup-go#v2
with:
go-version: '1.19'
- name: Install firebase
run: curl -sL https://firebase.tools | bash
- name: Run firebase emulators
run: firebase emulators:start --only auth &
- name: Run coverage
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action#v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

Related

Unable to deploy firebase functions with Github actions, it doesn't recognize a firebase project using Google service account for authentification

I'm following this Medium article to deploy firebase functions using Github actions.
This is the workflow in .github/workflows/firebase-deploy.yml
name: Deploy Cloud Functions
on:
workflow_dispatch:
push:
branches:
- master
- pre-production
- github-actions
- "feature/**"
paths:
- "functions/**"
jobs:
build_and_deploy:
runs-on: macos-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: 16.x
- uses: actions/cache#v2
with:
path: ~/.npm
key: macOS-node-${{ hashFiles('**/functions/package-lock.json') }}
restore-keys: |
macOS-node-
- name: Build Cloud Functions
run: npm ci
working-directory: functions
- name: Create SA key
run: echo '${{ secrets.FIREBASE_DEV_SERVICE_ACCOUNT }}' > gcloud.json
working-directory: functions
- name: Print json
run: echo "$(cat gcloud.json)"
working-directory: functions
- name: Install firebase tools
run: npm install -g firebase-tools
working-directory: functions
- name: Deploy Cloud Functions
run: export GOOGLE_APPLICATION_CREDENTIALS=gcloud.json && npx firebase-tools deploy --only functions --json
working-directory: functions
In the step Deploy Cloud Functions of the github action, I get the following error:
Run export GOOGLE_APPLICATION_CREDENTIALS=gcloud.json && npx firebase-tools deploy --only functions --json
export GOOGLE_APPLICATION_CREDENTIALS=gcloud.json && npx firebase-tools deploy --only functions --json
shell: /bin/bash -e ***0***
***
"status": "error",
"error": "No project active, but project aliases are available.\n\nRun \u001b[1mfirebase use <alias>\u001b[22m with one of these options:\n\n dev (web3army-pre-prod)\n prod (blockchainarmy-6ed76)"
***
Error: Process completed with exit code 1.
When deploying normally on the terminal without github actions, I use firebase use dev. Here the project dev is specified inside the json that I created with the google service account and also used to create the secret in the repo as explained in the tutorial. It seems like that GOOGLE_APPLICATION_CREDENTIALS is not initialized correctly with gcloud.json.
I tried to print the content of the json to check if it was okay but the result is encrypted with ***, so it's difficult to understand what is going wrong. Thanks a lot.

Why is my pipeline failing? error: option '--token <token>' argument missing

Im trying to setup a CI/CD pipeline but it keeps failing for my react app.
here is the script:
image: node:latest
.deploy: &deploy
- npm install -g firebase-tools
- firebase use $FIREBASE_PROJECT_ID --token $FIREBASE_TOKEN
- yarn
- yarn build
stages:
- deploy
deploy_preview:
stage: deploy
before_script:
- *deploy
script:
- firebase hosting:channel:deploy $FIREBASE_PROJECT_ID --token $FIREBASE_TOKEN
- echo "ENVIRONMENT_URL=$(firebase hosting:channel:open live --non-interactive | tail -1 | awk '{ print $3 }')"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
staging:
stage: deploy
before_script:
- *deploy
only:
- staging
script:
- firebase deploy -m "Pipe $CI_PIPELINE_ID Build $CI_BUILD_ID" --only hosting:staging --non-interactive --token $FIREBASE_TOKEN
production:
stage: deploy
before_script:
- *deploy
only:
- main
when: manual
allow_failure: false
script:
- firebase deploy -m "Pipe $CI_PIPELINE_ID Build $CI_BUILD_ID" --only hosting:prod --non-interactive --token $FIREBASE_TOKEN
but I keep getting the error:
added 612 packages in 22s
34 packages are looking for funding
run `npm fund` for details
$ firebase use $FIREBASE_PROJECT_ID --token $FIREBASE_TOKEN
error: option '--token <token>' argument missing
Cleaning up project directory and file based variables
ERROR: Job failed: exit code
from gitlab about why the pipeline is failing
Im not sure why its complaining about the token. I do have the gitlab variables also set up correctly.
Found out that its because the var was PROTECTED, which means only the branches that were PROTECTED would work with it

Unable to deploy firebase functions from github action

I have seen similar questions to this but I have a specific use case here which maybe be of interest, I am receiving an error which obviously means firebase-functions is not being installed properly on docker container, everything work fine on local.
Entire deployment works perfect and file structure created in docker container looks right, with node_modules being placed in correct folder, everything.
Does docker need to be enabled to expose port to firebase deploy to get correct download? Anyone have experience with this?
Error
[2022-10-08T08:09:34.513Z] Building nodejs source
i functions: Loaded environment variables from .env.development.
[2022-10-08T08:09:34.518Z] Could not find functions.yaml. Must use http discovery
[2022-10-08T08:09:34.533Z] Error: spawn ./node_modules/.bin/firebase-functions ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
action.yml
deploy-cloud:
name: Deploy Cloud
needs: e2e-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: '16'
- name: Checkout Repo
uses: actions/checkout#master
- name: Make envfile
uses: docker://xxxxxx/create-envfile:master
with:
...env vars...
directory: functions
file_name: .env.development
fail_on_empty: false
- name: Install Dependencies
working-directory: functions
run: yarn
- name: Build
working-directory: functions
run: yarn build
- name: Deploy to Firebase
uses: docker://xxxxxx/firebase-action:master
with:
args: deploy --project development --only functions --debug
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
Dockerfile for deploy action
FROM node:16.16.0-buster
LABEL version="0.0.1"
LABEL repository="https://github.com/xxxxxx/firebase-action"
LABEL homepage="https://github.com/xxxxxx/firebase-action"
LABEL maintainer="xxxxxx"
LABEL com.github.actions.name="GitHub Action for Firebase"
LABEL com.github.actions.description="Wraps the firebase-tools CLI to enable common commands."
LABEL com.github.actions.icon="package"
LABEL com.github.actions.color="gray-dark"
RUN apt update && apt-get install -y jq openjdk-11-jre
RUN npm i -g npm#8.10.0
RUN npm i -g firebase-tools#11.8.0
COPY LICENSE README.md /
COPY "entrypoint.sh" "/entrypoint.sh"
ENTRYPOINT ["/entrypoint.sh"]
CMD ["--help"]
I can confirm downgrading to firebase-tools 10.0.0 fixes this issue

Deploying firebase cloud functions using github actions

I'm trying to deploy my firebase cloud functions app using github actions:
name: Deploy
'on':
push:
branches:
- main
jobs:
deploy_to_production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: install dependencies
run: cd functions/ && npm install
- name: deploy to production
uses: w9jds/firebase-action#master
with:
args: deploy --only functions
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
The step "deploy to production" is not successful. I activate debug mode and I don't actually receive any useful information:
##[debug]Evaluating: secrets.FIREBASE_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'FIREBASE_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating condition for step: 'deploy to production'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: deploy to production
##[debug]Loading inputs
##[debug]Loading env
Run w9jds/firebase-action#master
with:
args: deploy --only functions
env:
FIREBASE_TOKEN: ***
/usr/bin/docker run --name w9jdsfirebaseactionv212_2c5197 --label 08450d --workdir /github/workspace --rm -e FIREBASE_TOKEN -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_DEBUG -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/personalsite-backend/personalsite-backend":"/github/workspace" w9jds/firebase-action:v2.1.2 deploy --only functions
##[debug]Docker Action run completed with exit code 2
##[debug]Finishing: deploy to production
Am I missing something?
Note: Locally I can deploy without any problem.
By using w9jds/firebase-action, there's a known issue wherein if you use uses: w9jds/firebase-action#master, it tries to store what the CLI spits out and if it errors out and ends the action before it can echo it this might stop it from printing out the response. More information from the repository owner here.
Starting with version v2.1.2, you must replace this line:
uses: w9jds/firebase-action#master
to this:
uses: docker://w9jds/firebase-action:master
More information here.
Moreover, there is also an alternate solution to this by using actions/checkout instead. See yaml configuration below:
name: Deploy to Firebase Functions via github action
"on":
push:
branches:
- main
env:
CI: false
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Download deps
working-directory: functions
run: npm install
- name: Deploy
run: npx firebase-tools deploy
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
Note: I've used actions/checkout#v2 on the sample yaml above, but v3 is now available.

Deploy Gatsby to Firebase using Circleci

I followed this blog to deploy my Gatsby site to Firebase using circleCI
https://circleci.com/blog/automatically-deploy-a-gatsby-site-to-firebase-hosting/
The config.yml file is as follows
# CircleCI Firebase Deployment Config
version: 2
jobs:
build:
docker:
- image: circleci/node:10
working_directory: ~/gatsby-site
steps:
- checkout
- restore_cache:
keys:
# Find a cache corresponding to this specific package-lock.json
- v1-npm-deps-{{ checksum "package-lock.json" }}
# Fallback cache to be used
- v1-npm-deps-
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: v1-npm-deps-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- run:
name: Gatsby Build
command: npm run build
- run:
name: Firebase Deploy
command: ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
This caused an error
#!/bin/bash -eo pipefail
./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
/bin/bash: ./node_modules/.bin/firebase: No such file or directory
Exited with code exit status 127
CircleCI received exit code 127
I haven't used yml files or focused on devops before so did some digging around. Found a few other people with this issue and there was a suggestion to use workspaces and workflow. So I amended my yml file to support this
# CircleCI Firebase Deployment Config
version: 2
jobs:
#build jobs
build:
docker:
- image: circleci/node:10
working_directory: ~/gatsby-site
steps:
- checkout
- restore_cache:
keys:
# Find a cache corresponding to this specific package-lock.json
- v1-npm-deps-{{ checksum "package-lock.json" }}
# Fallback cache to be used
- v1-npm-deps-
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: v1-npm-deps-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- persist_to_workspace:
root: ./
paths:
- ./
- run:
name: Gatsby Build
command: npm run build
- persist_to_workspace:
root: ./
paths:
- ./
# deploy jobs
deploy-production:
docker:
- image: circleci/node:10
steps:
- attach_workspace:
at: ./
- run:
name: Firebase Deploy
command: ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
workflows:
version: 2
build:
jobs:
#build
- build
#deploy
- deploy-production:
requires:
- build
Same issue
#!/bin/bash -eo pipefail
./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
/bin/bash: ./node_modules/.bin/firebase: No such file or directory
Exited with code exit status 127
CircleCI received exit code 127
I assume it must be something to do with the paths and it's looking in the wrong directory? Any idea of how I can get it to find the module required?
Apparently I can't read. The fix was in the instructions
We’ll also need to install the firebase-tools package locally to our
project as a devDependency. This will come in handy later on when
integrating with CircleCI, which does not allow installing packages
globally by default. So let’s install it right now:
npm install -D firebase-tools

Resources