We would do as a step by step tutorial. And it would be very easy to follow
You should have a Spring Boot application that you have tested locally on your computer.
A Github account (if not, sign up for free at www.github.com)
A Heroku account(sign up for free at www.heroku.com)
2. Push Your Application to Github
Follow the steps below to push your application from Spring to Github
Step 1: Create a repository in Github (this is very easy to do!)
Step 2: In Spring Tool Suite, right-click on your project and choose “Show in Local Terminal” > “Git Bash”)
If you don’t see Git Bash, then follow step 3 below
Step 4: Initialize a local Git repository using the command below in the terminal
$ git init
Step 5: Add your project files to the local git repository. This stages them for the first commit
$ git add . # Adds the files in the local repository and stages them for commit.
Step 6: Now commit the file from your workspace repository to the local repository
$ git commit -m "The first commit" # Commits the tracked changes and prepares them to be pushed to a remote github repository.
Step 7: Go to Github and copy the remote repository url. It ends in .git
Step 8: Add the remote repository url you copied and verify the remote repository. Use the command below
$ git remote add origin <remote-repository-url> $ git remote -v # Verifies the remote repository URL
Note: origin is the name we choose. You are free to use another name
Step 9: Now you can push the files to remote github repository using the command below
$ git push origin master # Pushes the changes in your local repository up to the remote repository
At this point, you can go to Github and check that the files are there.
Note: If for any reason, you want to remove a local repository, use the command below:
$ git remote rm <name-of-repository>
3. Deploy from Github to Heroku
Also follow the steps below. This would be shorter and easier!
Step 1: Login to your account in Heroku and create an App. Just specify the name of the app and click on Create. This is shown below
Step 2: In the Deployment method, click on Github
Step 3: Follow the procedure to connect go Github
Step 5: Then after it finds the repository, Click on Connect
Step 6: After a successful connection, then click on Deploy Branch
Step 7: If the deployment is successful, then you will see a link “View”. Click on it and your application is life!
In the next part, we would be looking at how to automate the process. If you have challenges, then watch the step by step video tutorial.