How to Integrate Travis CI/CD with GitHub

Tarun Nagpal
3 min readSep 27, 2020
Photo by Christina Morillo from Pexels

I am a huge Fan of Github and AWS and during my last project, I got a chance to work on a new tool named travis (https://travis-ci.com/).

I found it really cool and simple to use along with many features. So, with the habit of sharing and exploring, I created this post for the same.

I have divided the whole process into 9 Easy Steps and you can follow them to “Integrate Travis CI/CD with GitHub”.

Although I have tried to keep things as simple as possible if you still found something ambiguous.

Please let me know in the comments section. Lets Start :)

  1. Signup for Travis (https://travis-ci.com/signin) via Github
SignUp Page
(SignUp Button)
(Authorize the Details)

2. Open the Page (https://travis-ci.com/getting_started)

3. Activate your GitHub repositories — In this step, we are allowing our Github repository to be accessible from travis.

Expected URL Like below —

https://github.com/apps/travis-ci/installations/new/permissions?suggested_target_id=xxxxxxx

4. Get the Desired AWS details

You need the following AWS details in order to set up the process

AWS_KEY — XXX
AWS_SECTRET_KEY - XXX
BUCKET_NAME - XXX

5. Setup Environment variables

In this step, we will add environment variables. Please take care that you should add all sensitive information (like AWS key) in environment variables only. Adding private keys to, travis.yml will lead to security issues.

5.1 Goto repository page — Example

 (example https://travis-ci.com/github/tarun-nagpal-github/charts-travis-poc)

5.2 Click on More Options (on Right side) and then the settings button.

5.3 Add the desired variables. Please contact your DevOps/IT team for AWS details

AWS — Environment Variables
Environment Variables

6. Add a .travis.yml file to your repository

In order for Travis CI to build your project, you’ll need to add a .travis.yml configuration file to the root directory of your repository.

Setup your .YML file in Step 7

If a .travis.yml is not in your repository or is not valid YAML, Travis CI will ignore it.

You can find a sample of all supported languages here (Language-specific Guides — Travis CI)

7. Setup your .travis.yml

In this step, we will set up the .travis.yml. Please be careful about the name of the file its .travis.yml (dot) file.

7.1 Start your file with language and the version.

7.2 Setup before_install section

before_install section

7.3 Add before_script and script section

(I have used Echo Just for Messages)

7.4 (Optional) Set Git submodules to false — It will stop the unwanted running of gitsubmodules

7.5 Add your S3 Bucket Information

It includes 3 sections before_deploy, deploy and after_deploy

8. Validate your YML file here (http://www.yamllint.com/)

It is very important that you validate the file before uploading it to Github. Invalid YML will leads to an Error in build

9. Trigger your build

Now we have all the required files(.travis.yml) and settings (Env variables), its time to trigger the build.

All you need to do now is commit it to your local git history and git push it to GitHub. Your build will be triggered and the progress can be seen easily.

Summary of the Build

--

--