TejasQ / basically-continuous-deployment

A simple project that aims to explain the process of continuous deployment.

Home Page:https://tejasq.github.io/basically-continuous-deployment/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basically, Continuous Deployment

Build Status

This project was created to help introduce the concept of Continuous Deployment to anyone interested.

Basically how it works is:

  • You git push to a GitHub (or something else) server.
  • The git server uses a WebHook to connect with a CI/CD system.
  • The CI/CD thing builds your project, and deploys it somewhere.

Simple, right? This webpage actually, was built with a Continuous Deployment script!

Check out the source code to understand how it works.

How does this project work?

Glad you asked!

  • It was created with create-react-app.
  • It uses Travis CI as the CI/CD thing, which starts a new build on git push.
  • When Travis starts a new build, it executes this script.
  • I highly recommend reading the deploy script above. It is heavily documented for you in true Basically fashion, in order to help you understand what's actually happening.
  • After Travis is done, everything's deployed on gh-pages, and things are live.

What's this about keys? 🗝

Basically, Travis is going to be pushing to your GitHub account. Travis needs to be able to say HEY IM TEJAS in order to use Tejas' GitHub: it needs my key; my SSH key.

And so, I've got to:

  • Generate some keys:
    • In a terminal, type:
      ssh-keygen -t rsa -b 4096 -C "hello@tej.as" # YOUR EMAIL HERE
    • It'll ask you where to save it. Save the key somewhere familiar.
    • It'll ask you for a passphrase. I usually leave this blank.
    • It'll generate 2 files for you:
      • One ending with .pub (make a note of this).
      • And one with the name you gave it.
  • Encrypt them with Travis:
    • Make sure you have the Travis CLI installed.
    • In the terminal, run:
      travis encrypt-file WHATEVER_YOU_NAMED_YOUR_KEY
    • It will then create a .enc file based your key's filename.
    • It'll also say something back to you like:
      openssl aes-256-cbc -K $encrypted_0a6446eb3ae3_key -iv $encrypted_0a6446eb3ae3_key -blah blah
    • Copy the portion where we have 0a6446eb3ae3 written above. You'll need it.
  • Add them (the encrypted ones!) to my project:
    • At this point, you have add your .enc file to your git repo and commit it.
    • You can throw away your key at this point.
  • Tell Travis how to decrypt them:
  • Add the keys to my GitHub account:
    • The last step is actually adding the public part of your key to your GitHub profile to say "yes, the Travis thing using my key is basically me".
    • Go here, click the green New SSH Key, and paste the contents of your .pub file in the key field, giving it an appropriate title.
    • Bam!

Whew! Now, Travis can properly push your shiny new gh-pages to your GitHub project.

Thanks to

About

A simple project that aims to explain the process of continuous deployment.

https://tejasq.github.io/basically-continuous-deployment/

License:MIT License


Languages

Language:JavaScript 61.5%Language:Shell 19.2%Language:CSS 11.1%Language:HTML 8.2%