Edgio

Deployments

A deployment is required to apply changes to your code or configuration to an environment.

Deploying

Deploy to an environment using either of the following methods:
  • Edgio Console: Use this method to deploy changes made within the Edgio Console.
    1. Load the desired environment.
      1. From the Edgio Console, select your private space or the desired organization.
      2. Select the desired property.
      3. From the left-hand pane, select the desired environment from under the Environments section.
    2. Update your hostname, origin, or rule configuration.
    3. From the notification bar at the top of the page, click Deploy Changes.
      Deploy Changes
  • Edgio CLI: Use this method to deploy changes to your CDN-as-code configuration from your local machine (e.g., changes to edgio.config.js or routes.[js|ts]).
    Bash
    1edgio deploy [<ORGANIZATION>] [--environment=<ENVIRONMENT>]
    If you omit the environment argument, then the deployment will be applied to the default environment.
    The CLI will automatically detect your property’s framework, create an optimized production build, and upload it to Edgio. This takes about a minute for most applications.
    Once the deployment is complete, the CLI will output the URL for your site. Your property’s name is automatically derived from the name field in package.json. This can be overridden by using --property option when running edgio deploy.
Your initial CDN-as-code deployment will generate system-defined origin configurations along with those defined within your edgio.config.js. Learn more about system-defined origins.
Upon deploying a build, view deployment information from within the Edgio Console by navigating to the desired environment, clicking on Deployments, and then clicking the deployment’s version number.
Deployment version number
This deployment-specific page provides information about the deployment, such as:
  • How and when it was deployed.
  • Current status.
  • URL(s) through which you can serve traffic for your website. These URL(s) are listed under the URL section.
  • If you are using CDN-as-code, then we also provide:
    • A permalink for testing your site. This type of link bypasses the edge of our network and serves traffic directly from the Edgio cloud.
    • Server logs through which you can view console messages defined within your application.

Deployment Status

View status information for all deployments from the Deployments page. Online deployments are indicated by
Solid green circle
, while retired deployments are indicated by
Faint green circle
.
Paying customers may have up to 10 online deployments per environment, while free customers are restricted to 3 online deployments. If you are using CDN-as-code, then you may use the permalink associated with any online deployment to test your site.
Although older deployments are considered retired, you may revive a deployment by visiting its permalink. Once the deployment has been revived, the permalink will once again load your site. Additionally, we will retire the next oldest online deployment.

Versioning

Upon deploying changes, Edgio assigns a unique version number to the deployment. This allows you to track the changes deployed to this environment.
Key information:
  • Edgio increments this version number by 1 for each new deployment.
  • You can quickly roll back to any previous version. For example, you may wish to roll back to a previous deployment when a breaking change is introduced into an environment.
  • Each deployment is also assigned an environment version number. Deploying new changes increments both the deployment and the environment version number. However, rolling back to a previous environment version will only increment the deployment version number. The environment version number, on the other hand, will be set to the environment version to which you rolled back.
To roll back to a previous version
  1. Load the Deployments page.
    1. From the Edgio Console, select the desired private space or organization.
    2. Select the desired property.
    3. From the left-hand pane, select the desired environment from under the Environments section.
    4. From the left-hand pane, select Deployments.
  2. Find the deployment that should be applied to this environment, click its
    Menu
    icon, and then click Rollback to this version.
    Rollback Deployment
  3. When prompted, click Promote to production to confirm that a previous deployment will be applied to this environment.

Branches and Deployments

Deploying changes to Edgio generates a deployment build. Upon the completion of this deployment, this build is assigned a unique and permanent URL based on the organization name, property name, branch name in source control, and an incrementing deployment number. If you use Git, the branch name is set by default. If not, you can specify the --branch option when running edgio deploy.
Deployments
Permanently accessible deployment builds allows you to preview other developers’ work before merging a pull request and enables you to “go back in time” to find where a bug or change in behavior originated. We recommend configuring your CI environment to deploy every push to Edgio.

Deploy from CI

When configuring CI, we recommend:
  • Automatically deploying to your staging environment when a PR is merged to the master branch of your repo.
  • Manually promoting deployments to production using the Edgio Console to prevent unwanted builds from being published by misconfigured CI workflows.
A deploy token is required to deploy from your CI environment. Create one from the Settings page in the Edgio Console.
deployments
Use the --token option when deploying from your CI script:
Bash
1edgio deploy my-site --token=$EDGIO_DEPLOY_TOKEN
You should always store your deploy token using your CI environment’s secrets manager. Never commit your deploy token to source control.

GitHub Actions

You need to configure the following items in order to get a GitHub action set up.
  1. Create a deploy token (see Deploying from CI). Copy the value of that token for use in the next step.
  2. Save the deploy token inside GitHub (more info). Go to your GitHub project > Settings > Secrets > New repository secret. Save the item as EDGIO_DEPLOY_TOKEN.
  3. Inside your development project, create a top level folder titled .github. Inside that create a workflows folder. From there create a edgio.yml file and use the example below for its content.
This sample GitHub action deploys your site to Edgio. It requires:
  • A default environment. By default, new properties created through our CLI include a default environment. This Github action creates a new build for every push to the default environment.
  • A production environment. If you have not already created a production environment, then you should do so now.
  • A deploy token. Add this deploy token as a secret in your repository called edgio_deploy_token. Learn more on accessing environment variables which might be essential for your app during the build time and for server-side requests (including SSG/SSR).
  • Depending on your use of npm or Yarn, adjust the Install packages step.

Template

YAML
1# File: .github/workflows/edgio.yml
2# Purpose: Deploy to Edgio upon specific GitHub events.
3
4# Deployment Rules:
5# - "main" branch -> Default Environment
6# - Feature branch -> Staging (on PR)
7# - GitHub Release -> Production
8
9# Prerequisites:
10# - Set "EDGIO_DEPLOY_TOKEN" secret, generated from https://edgio.app
11# - Add `edgio:deploy` in package.json (Example: https://github.com/edgio-docs/edgio-docs/blob/main/package.json#L9)
12# - Create additional staging and production environments in https://edgio.app
13
14name: Deploy branch to Edgio
15
16on:
17 push:
18 branches: [main]
19 pull_request:
20 release:
21 types: [published]
22
23jobs:
24 deploy-to-edgio:
25 name: Deploy to Edgio
26 # Skip for auto-merge push on release tagging
27 if: contains(github.ref, 'refs/tags') == false || github.event_name == 'release'
28 runs-on: ubuntu-latest
29 env:
30 deploy_token: ${{ secrets.EDGIO_DEPLOY_TOKEN }}
31
32 steps:
33 # Validate presence of deploy token
34 - name: Validate Deploy Token
35 if: env.deploy_token == ''
36 run: echo "EDGIO_DEPLOY_TOKEN missing" && exit 1
37
38 # Extract and sanitize branch name
39 - name: Extract Branch Name
40 shell: bash
41 run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_ENV
42
43 # Checkout code and set up Node.js
44 - uses: actions/checkout@v1
45 - uses: actions/setup-node@v1
46 with:
47 node-version: 16
48
49 # Cache node modules
50 - name: Cache Node Modules
51 uses: actions/cache@v1
52 with:
53 path: ~/.npm
54 key: ${{ runner.os }}-build-${{ env.cache-name }}-$&lcub;&lcub; hashFiles&lpar;&apos;&midast;&midast;&sol;package-lock&period;json&apos;&rpar; &rcub;&rcub;
55 restore-keys: |
56 ${{ runner.os }}-build-${{ env.cache-name }}-
57 ${{ runner.os }}-build-
58 ${{ runner.os }}-
59
60 # Install packages (Adjust based on package manager)
61 - name: Install Packages
62 run: npm ci
63
64 # Deploy
65 - name: Deploy to Edgio
66 run: npm run edgio:deploy -- --branch=$BRANCH_NAME --token=$deploy_token \
67 ${{ github.event_name == 'push' && '--environment=default' || '' }} \
68 ${{ github.event_name == 'pull_request' && '--environment=staging' || '' }} \
69 ${{ github.event_name == 'release' && '--environment=production' || '' }}

Screencast Tutorial

Jenkins Pipeline

Here is an example Jenkins pipeline that deploys your site to Edgio:
This guide assumes:
  • Your project is hosted on GitHub
  • You have a Jenkins environment configured with Docker and to receive GitHub push events
  • You have created environments called “staging” and “production”
  • You have created a deploy key for your site and added it as an environment variable in your Jenkins configuration called “edgio_deploy_token”.
Groovy
1// Add this file to your project at ./Jenkinsfile
2//
3// This Jenkins pipeline deploys your site on Edgio.
4//
5// The site is deployed each time commits are pushed. The environment to which the changes are deployed
6// is based on the following rules:
7//
8// 1.) When pushing to `master`, changes are deployed to the "staging" environment. This environment does not exist
9// by default. You must create it using https://edgio.app.
10// 2.) When pushing to any other branch, changes are deployed to the default environment. An unique URL is created
11// based on the branch and deployment number.
12// 3.) To deploy to the "production" environment, use https://edgio.app to promote the build. This environment does not
13// exist by default, you must create it using https://edgio.app.
14//
15// In order for this pipeline to deploy your site, you must create a deploy token from the site settings page
16// in https://edgio.app and configure it as an environment variable called "edgio_deploy_token" in your Jenkins configuration.
17
18pipeline {
19 agent {
20 docker {
21 image "node:14-alpine"
22 }
23 }
24 environment {
25 REPO_URL = "https://github.com/{your-org}/{your-repo}/" // (required)
26
27 npm_config_cache = "npm-cache"
28 HOME = "."
29 }
30 stages {
31 stage("Checking environment") {
32 when {
33 expression {
34 env.edgio_deploy_token == null
35 }
36 }
37 steps {
38 echo "You must define the 'edgio_deploy_token' secret in your environment variables"
39 sh "exit 1"
40 }
41 }
42 stage("Install packages") {
43 steps {
44 sh "npm i"
45 }
46 }
47 stage("Deploy to Edgio") {
48 steps {
49 script {
50 def branch = env.GIT_BRANCH // typically referenced as `origin/{branch}`
51 def url = env.REPO_URL
52 env.EDGIO_COMMIT_URL = (url.endsWith("/") ? url : url + "/") + "commit/$GIT_COMMIT"
53 env.BRANCH_NAME = branch.tokenize("/").last()
54 env.EDGIO_ENV_ARG = (env.BRANCH_NAME != "master") ? "--branch=$BRANCH_NAME" : "--environment=staging"
55 }
56 sh "npm run deploy -- --token=$edgio_deploy_token ${EDGIO_ENV_ARG} --commit-url=${EDGIO_COMMIT_URL}"
57 }
58 }
59 }
60}

GitLab CI/CD

Here is an example GitLab CI/CD configuration that deploys your site to Edgio:
This guide assumes:
  • Your repository is hosted on GitLab
  • Your default git branch is named master or main
  • You have created environments called “staging” and “production”
  • You have created a deploy key for your site and added it as a variable in your GitLab project’s CI/CD settings page, named “EDGIO_DEPLOY_TOKEN”
YAML
1# Add this file to your project at .gitlab-ci.yml
2#
3# This GitLab CI/CD configuration deploys your site on Edgio.
4#
5# The site is deployed each time commits are pushed. The environment to which the changes are deployed
6# is based on the following rules:
7#
8# 1.) When pushing to master or main, changes deployed to the "staging" environment. This environment does
9# not exist by default. You must create it using https://edgio.app.
10# 2.) When pushing to any other branch, changes are deployed to the default environment. A unique URL is
11# created based on the branch and deployment number.
12# 3.) When you push a tag to GitLab, it will be deployed to the production environment. This environment does
13# not exist by default, you must create it using https://edgio.app. Therefore, you can push to
14# production by creating a tag, or by using the "Promote to Environment" menu when viewing a deployment
15# in https://edgio.app.
16#
17# In order for this pipeline to deploy your site, you must create a deploy token from the site settings page
18# in https://edgio.app and configure it as a variable called "EDGIO_DEPLOY_TOKEN" in your GitLab
19# project's settings page. You should mask this variable to prevent it from appearing in logs.
20
21image: node:16
22
23stages:
24 - deploy
25
26cache:
27 key: npm
28 paths:
29 - .npm/
30
31edgio_deploy:
32 stage: deploy
33 rules:
34 - if: '$CI_PIPELINE_SOURCE != "push"'
35 when: never
36 - if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main"'
37 variables:
38 EDGIO_DEPLOY_ENVIRONMENT: 'staging'
39 - if: '$CI_COMMIT_TAG'
40 variables:
41 EDGIO_DEPLOY_ENVIRONMENT: 'production'
42 - if: '$CI_COMMIT_BRANCH'
43 variables:
44 EDGIO_DEPLOY_ENVIRONMENT: ''
45 before_script:
46 - npm ci --cache .npm --prefer-offline
47 script:
48 - npm run edgio:deploy -- --token="$EDGIO_DEPLOY_TOKEN" --non-interactive --branch="$CI_COMMIT_BRANCH" --environment"$EDGIO_DEPLOY_ENVIRONMENT"