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.
-
Load the desired environment.
- From the Edgio Console, select your private space or the desired organization.
- Select the desired property.
- From the left-hand pane, select the desired environment from under the Environments section.
-
Update your hostname, origin, or rule configuration.
-
From the notification bar at the top of the page, click 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]
).Bash1edgio deploy [<ORGANIZATION>] [--environment=<ENVIRONMENT>]If you omit theenvironment
argument, then the deployment will be applied to thedefault
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 thename
field inpackage.json
. This can be overridden by using--property
option when runningedgio 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.
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 , while retired deployments are indicated by .
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
-
Load the Deployments page.
- From the Edgio Console, select the desired private space or organization.
- Select the desired property.
- From the left-hand pane, select the desired environment from under the Environments section.
- From the left-hand pane, select Deployments.
-
Find the deployment that should be applied to this environment, click its icon, and then click Rollback to this version.
-
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
.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.
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.
- Create a deploy token (see Deploying from CI). Copy the value of that token for use in the next step.
- Save the deploy token inside GitHub (more info). Go to your
GitHub project > Settings > Secrets > New repository secret
. Save the item asEDGIO_DEPLOY_TOKEN
. - Inside your development project, create a top level folder titled
.github
. Inside that create aworkflows
folder. From there create aedgio.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 adefault
environment. This Github action creates a new build for every push to thedefault
environment. - A
production
environment. If you have not already created aproduction
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.yml2# Purpose: Deploy to Edgio upon specific GitHub events.34# Deployment Rules:5# - "main" branch -> Default Environment6# - Feature branch -> Staging (on PR)7# - GitHub Release -> Production89# Prerequisites:10# - Set "EDGIO_DEPLOY_TOKEN" secret, generated from https://edgio.app11# - 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.app1314name: Deploy branch to Edgio1516on:17 push:18 branches: [main]19 pull_request:20 release:21 types: [published]2223jobs:24 deploy-to-edgio:25 name: Deploy to Edgio26 # Skip for auto-merge push on release tagging27 if: contains(github.ref, 'refs/tags') == false || github.event_name == 'release'28 runs-on: ubuntu-latest29 env:30 deploy_token: ${{ secrets.EDGIO_DEPLOY_TOKEN }}3132 steps:33 # Validate presence of deploy token34 - name: Validate Deploy Token35 if: env.deploy_token == ''36 run: echo "EDGIO_DEPLOY_TOKEN missing" && exit 13738 # Extract and sanitize branch name39 - name: Extract Branch Name40 shell: bash41 run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_ENV4243 # Checkout code and set up Node.js44 - uses: actions/checkout@v145 - uses: actions/setup-node@v146 with:47 node-version: 164849 # Cache node modules50 - name: Cache Node Modules51 uses: actions/cache@v152 with:53 path: ~/.npm54 key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}55 restore-keys: |56 ${{ runner.os }}-build-${{ env.cache-name }}-57 ${{ runner.os }}-build-58 ${{ runner.os }}-5960 # Install packages (Adjust based on package manager)61 - name: Install Packages62 run: npm ci6364 # Deploy65 - name: Deploy to Edgio66 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 ./Jenkinsfile2//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 deployed6// is based on the following rules:7//8// 1.) When pushing to `master`, changes are deployed to the "staging" environment. This environment does not exist9// 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 created11// 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 not13// 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 page16// in https://edgio.app and configure it as an environment variable called "edgio_deploy_token" in your Jenkins configuration.1718pipeline {19 agent {20 docker {21 image "node:14-alpine"22 }23 }24 environment {25 REPO_URL = "https://github.com/{your-org}/{your-repo}/" // (required)2627 npm_config_cache = "npm-cache"28 HOME = "."29 }30 stages {31 stage("Checking environment") {32 when {33 expression {34 env.edgio_deploy_token == null35 }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_URL52 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
ormain
- 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.yml2#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 deployed6# is based on the following rules:7#8# 1.) When pushing to master or main, changes deployed to the "staging" environment. This environment does9# 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 is11# 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 does13# not exist by default, you must create it using https://edgio.app. Therefore, you can push to14# production by creating a tag, or by using the "Promote to Environment" menu when viewing a deployment15# 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 page18# in https://edgio.app and configure it as a variable called "EDGIO_DEPLOY_TOKEN" in your GitLab19# project's settings page. You should mask this variable to prevent it from appearing in logs.2021image: node:162223stages:24 - deploy2526cache:27 key: npm28 paths:29 - .npm/3031edgio_deploy:32 stage: deploy33 rules:34 - if: '$CI_PIPELINE_SOURCE != "push"'35 when: never36 - 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-offline47 script:48 - npm run edgio:deploy -- --token="$EDGIO_DEPLOY_TOKEN" --non-interactive --branch="$CI_COMMIT_BRANCH" --environment"$EDGIO_DEPLOY_ENVIRONMENT"