Menu
AWS CodeDeploy
User Guide (API Version 2014-10-06)

Tutorial: Deploy an Application from GitHub Using AWS CodeDeploy

In this tutorial, you'll use AWS CodeDeploy to deploy a sample application revision from GitHub to a single Amazon EC2 instance running Amazon Linux, a single Red Hat Enterprise Linux (RHEL) instance, or a single Windows Server instance. For information about GitHub integration with AWS CodeDeploy, see GitHub.

Note

You can also use AWS CodeDeploy to deploy an application revision from GitHub to an Ubuntu Server instance. You can use the sample revision described in Step 2: Create a Sample Application Revision in Tutorial: Deploy an Application to an On-Premises Instance, or you can create a revision compatible with an Ubuntu Server instance and AWS CodeDeploy. To create your own revision, see Plan a Revision and Add an AppSpec File.

Step 2: Create a GitHub Repository

You will need a GitHub repository to store the revision.

If you already have a GitHub repository, be sure to substitute its name for CodeDeployGitHubDemo throughout this tutorial, and then skip ahead to Step 3: Upload a Sample Application to Your GitHub Repository.

  1. On the GitHub home page, do one of the following:

    • In Your repositories, choose New repository.

    • On the navigation bar, choose Create new (+), and then choose New repository.

  2. In the Create a new repository page, do the following:

    • In the Repository name box, type CodeDeployGitHubDemo.

    • Select Public.

      Note

      Selecting the default Public option means that anyone can see this repository. Although you can select the Private option to limit who can see and commit to the repository, this option may result in additional charges from GitHub.

    • Clear the Initialize this repository with a README check box. You will create a README.md file manually in the next step instead.

    • Choose Create repository.

  3. Follow the instructions to use the command line to create the repository.

    Note

    If you have enabled two-factor authentication on GitHub, make sure you enter your personal access token instead of your GitHub login password if prompted for a password. For information, see Providing Your 2FA Authentication Code.

    For Linux, macOS, or Unix:

    1. From the terminal, run the following commands, one at a time, where user-name is your GitHub user name:

      Copy
      mkdir /tmp/CodeDeployGitHubDemo
      Copy
      cd /tmp/CodeDeployGitHubDemo
      Copy
      touch README.md
      Copy
      git init
      Copy
      git add README.md
      Copy
      git commit -m "My first commit"
      Copy
      git remote add origin https://github.com/user-name/CodeDeployGitHubDemo.git
      Copy
      git push -u origin master
    2. Leave the command prompt open in the /tmp/CodeDeployGitHubDemo location.

    For Windows:

    1. From a command prompt running as an administrator, run the following commands, one at a time:

      Copy
      mkdir c:\temp\CodeDeployGitHubDemo
      Copy
      cd c:\temp\CodeDeployGitHubDemo
      Copy
      notepad README.md
    2. In Notepad, save the README.md file. Close Notepad. Run the following commands, one at a time, where user-name is your GitHub user name:

      Copy
      git init
      Copy
      git add README.md
      Copy
      git commit -m "My first commit"
      Copy
      git remote add origin https://github.com/user-name/CodeDeployGitHubDemo.git
      Copy
      git push -u origin master
    3. Leave the command prompt open in the c:\temp\CodeDeployGitHubDemo location.