Building and publishing applications to Fastly from CI

Applications written for Compute@Edge services can be compiled and tested outside the Fastly platform in many popular CI tools such as Jenkins, CircleCI or GitHub Actions. We have our own GitHub actions for Fastly, described below, or just use the Fastly CLI in other environments.

Code written for VCL services can only be compiled by Fastly. As a result the value of running automations for VCL services is lower, and while there are no tools created specifically to assist with automating processes relating to VCL services, many Fastly customers use Terraform or other orchestration tools to manage Fastly services, and those tools often have excellent support for running in CI environments. Learn more about using orchestration tools with Fastly.

GitHub Actions

GitHub Actions is a popular tool for running tasks on repositories in response to events such as pull requests being opened or merged. You can create workflows in GitHub Actions similarly to other CI tools by configuring the workflow to install and run the Fastly CLI, however we have created a set of pre-packaged workflows which make building and deploying Compute@Edge applications easier.

To compile and deploy a Compute@Edge service at the root of the repository, you can use the fastly/compute-actions main action. The following workflow will install the Fastly CLI, build your project (with dependencies and toolchains for the appropriate language), and deploy it to your Fastly service:

  1. Rust
  2. JavaScript
name: Deploy Application
branches: [master]
runs-on: ubuntu-latest
- uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
toolchain: 1.54.0 # current Rust toolchain for Compute@Edge
target: wasm32-wasi # WebAssembly target
- name: Deploy to Compute@Edge
uses: fastly/compute-actions@v5

Custom Workflows

Alternatively, you can manually run the individual GitHub Actions for Compute@Edge if you want finer control over your workflow:

  • fastly/compute-actions/setup - Download the Fastly CLI if not already installed
  • fastly/compute-actions/build - Build a Compute@Edge project. Equivalent to fastly compute build
  • fastly/compute-actions/deploy - Deploy a Compute@Edge project. Equivalent to fastly compute deploy
  • fastly/compute-actions/preview - Deploy a Compute@Edge project to a new Fastly Service, which is deleted when the pull-request is merged or closed.

For example, each time you open or update a pull request, you could create a temporary Fastly service to run the Compute@Edge application using the code updated in the PR, so you can test out the proposed change on the live Fastly platform before you merge the PR:

name: Fastly Compute@Edge Branch Previews
group: ${{ github.head_ref || github.run_id }}-${{ github.workflow}}
types: [opened, synchronize, reopened, closed]
runs-on: ubuntu-latest
shell: bash
- uses: actions/checkout@v3
- uses: fastly/compute-actions/preview@v5
fastly-api-token: ${{ secrets.FASTLY_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}

See the full documentation on GitHub for the actions for more examples and details about each of the possible input properties.

Using the Fastly CLI in CI

Nearly any CI environment can run the Fastly CLI, and it's a great way to automate the process of building and deploying Compute@Edge apps. To validate that your code builds, use fastly compute build and to deploy, fastly compute publish.

The --non-interactive flag can be used with many CLI commands to suppress prompts and ensure the process does not hang.