This repository contains GitHub Actions to help you build on Fastly's Compute platform, such as installing the CLI, and building and deploying services.
To compile and deploy a Compute service at the root of the repository, you can use the fastly/compute-actions main action. This will install the Fastly CLI, build your project, and deploy it to your Fastly service. If you used fastly compute init to initialise your project, this will work out of the box:
You will need to install the correct Rust toolchain for the action to build your project. The rust-toolchain action can handle this for you with the following configuration:
name: Deploy Applicationon:
push:
branches: [main]jobs:
deploy:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v4
- name: Install Rust toolchainuses: dtolnay/rust-toolchain@stablewith:
targets: wasm32-wasi # WebAssembly target
- name: Deploy to Computeuses: fastly/compute-actions@v13env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}GitHub Action runners come with a node toolchain pre-installed, so you can just run npm ci to fetch your project's dependencies.
name: Deploy Applicationon:
push:
branches: [main]jobs:
deploy:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v4
- name: Install project dependenciesrun: npm ci
- name: Deploy to Computeuses: fastly/compute-actions@v13env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}Since you need to pick Go version equal to 1.21 or later to build your Go project with GOARCH=wasm and GOOS=wasip1 target, it is recommended to use actions/setup-go with the following configuration, so that you can switch to any version of Go you need;
name: Deploy Applicationon:
push:
branches: [main]jobs:
deploy:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v4
- name: Install Go toolchainuses: actions/setup-go@v5with:
go-version: "1.23"
- name: Deploy to the Compute platformuses: fastly/compute-actions@v13env:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}Alternatively, you can manually run the individual GitHub Actions for Compute 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 project. Equivalent to
fastly compute build - fastly/compute-actions/deploy - Deploy a Compute project. Equivalent to
fastly compute deploy - fastly/compute-actions/preview - Deploy a Compute project to a new Fastly Service, which is deleted when the pull-request is merged or closed.
- fastly/compute-actions/staging - Build and stage a Compute project to the Fastly staging environment without activating it.
name: Deploy Applicationon:
push:
branches: [main]jobs:
deploy:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v4
- name: Set up Fastly CLIuses: fastly/compute-actions/setup@v13with:
cli_version: '1.0.0'# optional, defaults to 'latest'token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Dependenciesrun: npm ci
- name: Build Compute Packageuses: fastly/compute-actions/build@v13with:
verbose: true # optionally enables verbose output, defaults to false
- name: Deploy Compute Packageuses: fastly/compute-actions/deploy@v13with:
service_id: '4tYGx...'# optional, defaults to value in fastly.tomlcomment: 'Deployed via GitHub Actions'# optionalenv:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}name: Stage Applicationon:
push:
branches: [staging]jobs:
stage:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v4
- name: Install Dependenciesrun: npm ci
- name: Stage Compute Packageuses: fastly/compute-actions/staging@v12with:
service_id: '4tYGx...'# optional, defaults to value in fastly.tomlcomment: 'Staged via GitHub Actions'# optionalenv:
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}name: Fastly Compute Branch Previewsconcurrency:
group: ${{ github.head_ref || github.run_id }}-${{ github.workflow}}on:
pull_request:
types: [opened, synchronize, reopened, closed]jobs:
deploy:
runs-on: ubuntu-latestdefaults:
run:
shell: bashsteps:
- uses: actions/checkout@v4
- uses: fastly/compute-actions/preview@v13with:
fastly-api-token: ${{ secrets.FASTLY_API_KEY }}github-token: ${{ secrets.GITHUB_TOKEN }}The following inputs can be used as with keys for the actions in this repository; none of them are required:
project_directory- Directory of the project to deploy, relative to the repository root.cli_version- The version of the Fastly CLI to install, e.g. v0.20.0service_id- The Fastly service ID to deploy or stage to. Defaults to the value infastly.toml. (deploy and staging)comment- An optional comment to be included with the deployed or staged service version. (deploy and staging)version- Version to clone from when deploying. Can be "latest", "active", or the number of a specific version. (deploy only)verbose- Set to true to enable verbose logging.token- The GitHub token to use when interacting with the GitHub API.
Please see our SECURITY.md for guidance on reporting security-related issues.
The source and documentation for this project are released under the MIT License.