CI/CD NodeJS + CircleCi + Heroku Deployement
Abayomi Ogunnusi
Posted on June 11, 2022
_
Let's discuss about CircleCi and Continuous Delivery/Continuous Deployment.
Check out my CICI with Jenkins, which is another CircleCi alternative. _
🎯 Prerequisite
NodeJs and Express Knowledge
Heroku Account
CircleCi Account
To deploy Heroku, let's create up a very simple app.
Let create our server
Let's edit our package.json
and .env
files
Now we start our server
In this section 2 we will deploy to Heroku using the Heroku cli
Log in to Heroku
Create Heroku app
Let push our codes to Github at this stage
git init && git add . && git commit -m "Initial commit" && git branch -M main && git remote add origin https://github.com/drsimplegraffiti/cicd-heroku-circleci.git && git push -u origin main
Next we connect heroku to our apploid app
Let's add Port to Heroku Environment variable
We can deploy to Heroku
Open app on a browser
In this section, let's setup our circle with github. Head up to circleci and login with Github
Let's setup and connect our app in CircleCI
Click on the setup project button
Choose a deployment method
Choose deploy with Heroku
Set your env config on circle ci
Click and run
Let me copy the config file and do some editing on the yml
file
Setup the config.yml
file
Now click on commit and run. Lets see if our build was successful
Let's add another router called deploy
Notice we didnt run git push heroku main
. Let's if our deploy endpoint
is active. Open your browser and type:
https://apploid.herokuapp.com/deploy
Debugging failed build
I made this build fail on purpose in order to show you how to debug minor issues. Click on the failed button for details
This happened before i didnt add my Heroku api keys and heroku app name in the CircleCi Environment variable.Lets do that right now. Go to account settings on Heroku and copy the key and paste in the env varible on CircleCi
Go to CircleCi, under project settings
and add the env
Now open your browser to the our deployed url refelct on heroku
Conclusion
I hope this was helpful. Comment in the section below
Posted on June 11, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.