31
loading...
This website collects cookies to deliver better user experience
projects
and create a new project.Root-------------/spec/
|---/node_modules/
|--.gitignore
|--package.json
|--package.lock.json
.circleci
and create a file config.yml
inside this folder. This should give you a big hint, the configuration file for setting up a circle-ci workflow is written in yml, if you have used github acitons then the process becomes a lot more easier.Root-------------/spec/
|---/node_modules/
|--.gitignore
|--package.json
|--package.lock.json
|--/.circleci/config.yml
config.yml
file# You must choose a version of circle ci you want to use, all config files requires this
version: 2.1
# You can use already packaged circle ci workflows, they are called orbs
orbs:
node: circleci/[email protected] # We use the orbs for creating a node js workflow
jobs: # This is where we define our actual process, each process is classified into a job. we can run multiple jobs
# Each job should have a name, you can call it whatever you like
test-code:
# Executor, we must define one, you can use circle-ci's docker executors or your own custom docker executors
docker:
- image: cimg/node:15.1
# next we define the steps involved in creating the workflow
steps:
# Checkout the code as the first step. move our code to the host machine
- checkout
# Install our dependencies with npm, we can use circleci to cache dependencies them for future use
- node/install-packages
# We specify commands to run, each command has a name and the actual terminal command like below
- run:
name: Run tests
command: npm test
workflows:
# Below is the definition of your workflow.
# Inside the workflow, you provide the jobs you want to run, e.g this workflow runs the test-my-code job above.
# CircleCI will run this workflow on every commit.
sample:
jobs:
- test-code
From the command line run firebase login:ci
. This will return us a login credential in the command line, copy the credentials.
Head over to your circle-ci dashboard, navigate to the current project that we setup a CI for, enter project settings.
From the project settings select environment variables and add new environment variable.
It's name should be FIREBASE_TOKEN
paste in the login credentials that firebase gave to us as it's value.
config.yml
, we will be adding two commands, one to build the project and another to deploy the project.# PAY ATTENTION TO NEW JOBS ADDED
version: 2.1
orbs:
node: circleci/[email protected]
jobs:
test-and-deploy-code:
docker:
- image: cimg/node:15.1
# next we define the steps involved in creating the workflow
steps:
- checkout
- node/install-packages
- run:
name: Run tests
command: npm test
# This command builds the project, e.g a react or angular project
- run:
name: Build Project
command: npm run build
# This command deploys to the project to firebase using the FIREBASE_TOKEN we set earlier
- run:
name: Deploy Project
command: ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
workflows:
sample:
jobs:
- test-and-deploy-code
only build pull requests
.