Error during deploy from pipeline on firebase - firebase

I try to deploy my angular application on firebase using gitlab pipeline.
I followed this guide and I write a gitlab-ci file more simplified for starting.
image: node:latest
cache:
paths:
- node-modules/
stages:
- deploy
deploy:
stage: deploy
environment:
name: development
script:
- npm install -g firebase-tools
- npm install
- npm run builddev
- npm run deploy
only:
- master
Everything work until last command when I have this error
but if from terminal I run
firebase deploy --project test-1c121
everything work fine

Check your package.json file in scripts section. You probably have a typo in deploy because npm runs into problem with running firebse command and you want to run firebase.

Related

AWS Amplify - Automating Testing For A Dev Environment with Hosting

Problem: A variety of tutorials from AWS for integrating automated testing with CI/CD look to integrate the testing stage after, or within the build process by using a localhost:3000 server.
However, as AWS Amplify developers know, the local environment can sometimes offer a different user experience to deploying to a development environment, and using that environment with AWS Amplify's hosting service.
Therefore, how do I add testing not only at the build stage with localhost:3000, but also for the development environment's hosted url?
I'm looking to build all my resources (backend and front-end), with a git push to the code commit repository.
Idea of Stages:
Source
Build
Test
Deploy Cloud Formation Stacks
Test
Roll back if failure
Current amplify.yml:
Note: this currently does not work so please do not copy it for your build. Please refer to the hyperlink above.
version: 0.2
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
test:
phases:
preTest:
commands:
- npm ci
- npm install wait-on
- npm install pm2
- npm install mocha mochawesome mochawesome-merge mochawesome-report-generator
- npx pm2 start npm -- dev
- 'npx wait-on --timeout 300 http://localhost:3000'
test:
commands:
- 'npx cypress run --reporter mochawesome --reporter-options "reportDir=cypress/report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss"'
postTest:
commands:
- npx mochawesome-merge cypress/report/mochawesome-report/mochawesome*.json > cypress/report/mochawesome.json
- npx pm2 kill
artifacts:
baseDirectory: cypress
configFilePath: '**/mochawesome.json'
files:
- '**/*.png'
- '**/*.mp4'

Firebase Emulator on Bitbucket Pipeline

I'm trying to run Firebase Emulator on Bitbucket Pipeline. It fails because "java is not installed".
How can I "install java" on a Bitbucket Pipeline. Or is there another way to get it to work?
My step currently looks like this:
- step: &test-rules
name: 'Test Firestore Rules (DEV)'
image: node:16.13.2
script:
- npm ci --prefix firebase-test
- npm install -g firebase-tools
- npm run test --prefix firebase-test
npm run test runs this script:
firebase emulators:exec --only firestore "mocha --exit"

Github Actions Firebase error "command requires scopes"

I am transitioning my CI/CD over to Github Actions and noticed that my prior scripts for deploying Firebase do not work.
When I try to switch projects via firebase use staging --debug it errors with the error:
[2020-04-14T12:51:59.154Z] > 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"]
If I use firebase use --debug to see what project is active, I get
Error: No active project
These scripts work without fault on CircleCI so I am confused as to why they break on Github Actions. They also work perfectly in my local environment.
I have tried various versions of node, and installing the firebase tools, however they all result in the same error. I have generated a new token generated via firebase login:ci.
Here is a sample of my Github Actions workflow:
deploy_staging:
name: Deploy to staging
needs: eslint_test_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: "10.x"
...
- name: Deploy to Firebase
run: |
npm install -g firebase-tools
firebase -V # this will work
firebase use staging # this will fail
firebase functions:config:set sentry.dsn=$DSN
firebase deploy --only hosting:admin --token "$TOKEN" --non-interactive
env:
TOKEN: ${{ secrets.firebase_token }}
--update
When I just use deploy it works. Is the deploy Firebase CLI command the only one allowed for Github Actions?
This works:
- name: Deploy to Firebase
run: |
npm install -g firebase-tools
firebase deploy --only hosting:admin --project=staging --token "$TOKEN" --non-interactive

Docker Image For Deploying DotNet Core Output to Firebase

I'm struggling to create a BitBucket Pipeline script which can compile a DotNet Core application, run it and then deploy the output html files to Firebase using the CLI.
image: microsoft/dotnet:sdk
pipelines:
default:
- step:
caches:
- dotnetcore
script:
- dotnet restore
- dotnet build MySolution.sln
branches:
master:
- step:
caches:
- dotnetcore
script:
- dotnet restore
- dotnet build MySolution.sln
- cd MySolution
- dotnet run MySolution.
- npm install -g firebase-tool
- firebase deploy --token "$FIREBASE_TOKEN"
The image microsoft/dotnet:sdk doesn't contain npm or the Firebase-Tools package I require. I'm struggling to find an alternative Docker Image which contains both dotnet and npm / Firebase-Tools. Is there a simpler way to deploy the output of the application to Firebase directly from BitBucket?
I think you should dig into the multi-step approach of Bitbucket pipelines. There you will be able to run each of the steps with different docker images.
More documentation you may find at Bitbucket here
For example:
pipelines:
default:
- step:
name: Build and test
image: microsoft/dotnet:sdk
script:
- dotnet restore
- dotnet build
- dotnet publish -o /out -c Release
artifacts:
- out/**
- step:
name: Run npm
image: node:8
script:
- npm install -g firebase-tool
- firebase deploy --token "$FIREBASE_TOKEN"
- step
name: Run app
image: microsoft/dotnet:sdk
script:
- dotnet run MySolution .

Travis CI - failing to deploy to Firebase - Cannot find module 'ipaddr.js'

I added .travis.yml to my project and each time I commit to master branch, it runs all tests / scripts ok but last firebase deploy fails consistently with error like below:
But certainly I am installing dependencies under functions folder and can deploy on localhost with no problem.
My .travis.yml looks like:
language: node_js
node_js:
- 6
branches:
only:
- master
install:
- yarn
- CI=false yarn build:ssr
- yarn fns:deps
after_success:
- node_modules/.bin/firebase deploy --non-interactive --token "$FIREBASE_TOKEN" --project react-joanne
deploy:
provider: firebase
skip_cleanup: true
token:
secure: "$FIREBASE_TOKEN"
project: "react-joanne"

Resources