Wednesday, 28 July 2021

*Episode 29* PYTHON (Setting up Heroku Pipelines of Django)

 


Setting up Heroku pipelines


This episode covers :-


 1) How to create a continuous deployment workflow with Heroku pipelines.


  •  Setup :-

     Use the project from the “Heroku Deployment” chapter to test this.


  •  Creating a GitHub repository :-

     Visit https://samuli.to/GitHub and create an account.


     Create a new repository:



      Go to your project folder. Add a remote and push the code to GitHub:

Terminal

git remote add origin git@github.com:SamuliNatri/sn-01.git

git push -u origin master


     Refresh the GitHub page and you should see the project code:



  • Creating a pipeline :-

Visit your Heroku app Deploy page and create a pipeline:




      Press Connect to GitHub:



      Login to GitHub and Authorize heroku:



Search for the repository and Connect it:


     Visit the Pipeline page and Enable Automatic Deploys:



  •  Testing deployment :-

     Edit the index.html template and change the “Home” text:

blog/templates/blog/index.html

{% load static %}

<!DOCTYPE html>

<html lang="en">

<head>

<title>Blog</title>

<link rel="stylesheet" href="{% static 'blog/css/site.c\

ss' %}">

</head>

<body>

<div id="content">

<h1>Home (Update)</h1> # < here

</div>

</body>

</html>


Terminal

git add .

git commit -m "Update homepage"

git push


      In a moment you will see “Building app” text on the page:



      And “Deployed..” text when the deployment is ready:



      Visit the app URL and you should see the changes:



      These deployments will also show in the GitHub Deployments section:



  • Adding a production app :-

    Visit the Pipeline page:



     Add a Production app:






      Press your staging app Promote to production button:



Visit your production app homepage and it should look like the staging app homepage:


  • Enabling review apps :-

    Visit the Pipeline page and press Enable Review Apps:



       Create an app.json file:



       Scroll to the bottom and press Commit to Repo:


      Check Create new review apps…automatically and Destroy stale review apps.

     Press Enable:



      Note that review apps may incur dyno and add-on charges:

https://samuli.to/Review-Apps!


     You can also not check the Create new review apps…automatically option and create preview apps manually on the Pipeline page.


  • Using pull requests :-

    Let’s make a change and create a pull request.


    Pull changes and create a branch:

Terminal

git pull

git checkout -b new_homepage


     We need to pull the app.json file that the platform added to the repo.


     Edit the index.html template and make some changes:

blog/templates/blog/index.html

<div id="content">

<h1>NEW FANCY HOMEPAGE</h1> <!-- here -->

</div>


Terminal

git add .

git commit -m "New homepage suggestion"

git push --set-upstream origin new_homepage


     Use link in the Terminal to create a Pull request or visit the Pull requests page on GitHub:



     Write a description and create a Pull request:


    Visit the Pipeline page and click Open app in browser after the preview app is ready:



      You can now evaluate the pull request in the preview app:



     Visit GitHub and merge the pull request:



      Visit the Pipeline page and wait for the staging app to be deployed. Press Promote to production and the new fancy home page is now live:



     The pull request and merging flow is also visible in GitHub:



  •  Deleting the branch :-

    We don’t need the new_homepage branch anymore since it’s now merged to the master branch:

Terminal

git branch

git checkout master

git pull

git branch -d new_homepage


Summary :-


  • Heroku provides a nice continuous delivery workflow out of the box.
  • Review apps allow you to test GitHub pull requests with disposable Heroku apps.

👈Episode 28(P).                                                                           Episode 30(P)👉
Share this Post
PRINT THIS POST

No comments:

Post a Comment

If you have any doubts. Please let me know.

Featured post

*Episode 1* MCQ for Govt. Job/ Private Job/ MNCs

  Topic:- One Word Substitution 1) Especially skilled in storytelling  Answer:- Raconteur 2) Fear of loneliness Answer:- Eremophobia  3) Usa...