Deploy Applications using GitHub Actions

Use GitHub Actions to deploy your applications.

Version: 1.0
Last Modified: 5/15/2020

While the Edge-Cloud Console provides an easy way to deploy your applications, you can auto-deploy your applications to our cloudlets using GitHub Actions. This guide provides steps on how to integrate GitHub Actions into your own edge application that's hosted on Github. For reference, we have provided a sample repository containing sample files to help guide you in setting up your configuration to successfully deploy your application to our cloudlets.

Note: The current version of GitHub Actions only supports Docker and Kubernetes-based deployments. While the sample provided in this tutorial shows a Docker deployment, you can follow the same steps if you were to deploy using a Kubernetes-based deployment. Simply specify the deployment type as Kubernetes. However, if you do not specify a deployment type in your manifest, it will default to Kubernetes. See the example in app.yml.

Prerequisites

One-time setup to support GitHub Actions

You will only be required to setup your repository (Steps 1 through 4) once to support GitHub Actions.

  • Step 1: Set up username and password for the Docker repository
  • Step 2: Set up your application configuration files in the repository
  • Step 3: Optional: Configure your application instances
  • Step 4: Set up the GitHub workflow

Step 1: Set up username and password for the Docker repository

Add your console username and password as secrets to your Github repository. This creates an encrypted environment variable within the repository to be used with GitHub Actions.

  1. On GitHub, navigate to the main page of your repository.
  2. Under your repository name, click the Settings option.
  3. On the left sidebar, click Secrets.
  4. Type a name for your secret in the Name box.
  5. Type the values of your secret.
  6. Click Add secret.

    The username and password are stored as MOBILEDGEX_USERNAME and MOBILEDGEX_PASSWORD, which are used as variables in the configuration files. Refer to the main.yml file as an example.

    For more information about creating and storing secrets in GitHub, refer to Creating and storing encrypted secrets.

Step 2: Set up your application configuration in the repository

This step requires you to set up your application configuration files within the repository. The application configuration mirrors a standard application definition that you would normally provide through the Edge-Cloud Console. However, the only difference will be the image path, which does not require you to specify a version tag since the version tag will automatically be retrieved from the GitHub release.

  1. Within your repository, create a folder called .mobiledgex at the root.
  2. Within this folder, create a yaml file and name it app.yml.
  3. Define your application configuration using the template provided in our sample repository: app.yml.

Step 3 (Optional): Configure your application instances

If you decide to perform this optional step, you need to either specify an autocluster name or ensure that you define your cluster instance beforehand and specify the cluster instance within the application instance.

  1. Within your repository, navigate to the default path: .mobiledgex.
  2. Create a yaml file and name it appinstst.yml.
  3. Define your application instance configuration using the template provided in our sample repository: appinsts.yml.

Step 4: Set up the GitHub workflow

  1. Within your repository, create the path .github/workflows at the root.
  2. Under the newly created .github/workflows path, create a file and name it main.yml.
  3. Define your build workflow using our template provided in our sample repository: main.yml.

The main.yml sample file contains an ordered workflow that will run to deploy an application. The top of the main.yml file displays the workflow, as shown below.

on:
  release:
    types: [published]

Following the workflow are the rest of the steps. Our example uses two open source projects actions/checkout and docker/build-push-action , as show below. If you wish to customize the steps to check out a repository or push to Gitlab, refer to each project's documentation for instructions.

steps:

      - name: Check out the repo
        uses: actions/[email protected]

The following section of the sample file displays the Docker actions required to build and publish the Docker image to the registry. Make sure to change the repository name and path to match the name and path of the image you will be deploying.

The following section of the sample file uses this custom action, as shown below, to deploy your application to our cloudlets. You can learn more about this action from this repository.

Note: You can use the same workflow process as described above to perform different actions as long as you assign a different name for each workflow. In cases where you want to deploy your application to a specific cloudlet, for example, remember to specify the paths to appconfig and appinstsconfig. These optional parameters are defaulted to .mobiledgex/app.yml and .mobiledgex/appinsts.yml, respectively.

Step 5: Deploy the application

  1. Make any necessary changes within the code.
  2. Create a release.
    a. On GitHub, navigate to the main page of your repository.
    b. Under the repository name, click Releases.
    c. Click Draft a new release.
    d. Type a version number for your release.
    e. Select the branch that contains the project you want to release using the drop-down menu.
    f. Type a title and description for your release.
    g. Click Publish release.
    h. Click the Actions tab to watch the deployment.

    For more information on managing your releases on GitHub, refer to Managing your releases.

That's it! You have now learned how to use GitHub Actions to auto-deploy your application.

Where to go from here

Access other tutorials here: Guides and Tutorials