Builds and the GitHub Actions allowance
Fleet builds a site in GitHub Actions, in the site's own repository, only when you start a deploy or an update.
What it is
A build compiles your EmDash site into the bundle that Fleet uploads to your Cloudflare account. It runs as a GitHub Actions workflow in the site's repository, only when you start a deploy or an update. Fleet has no build server, does not use Cloudflare Workers Builds and never builds on a push.
How it works in Fleet
Two workflows. The repository holds two files under .github/workflows, both written by Fleet when it created the site:
fleet-build.ymlbuilds the site for a deploy.fleet-update.ymlprepares an EmDash or plugin update.
Each file starts only on workflow_dispatch, a start that a program or a person requests. A push, a pull request or a schedule never starts one. Fleet dispatches a workflow through its GitHub App installation when you select Deploy or start an update.
What a build does. The workflow checks out the commit Fleet names, installs the dependencies, builds the site and bundles the Worker. It stops after 30 minutes. It uploads the bundle as the artifact fleet-bundle-<job_id>, which GitHub keeps for 1 day. Fleet downloads the artifact and uploads it to your Cloudflare account. The workflow holds no Cloudflare or Fleet credential.
What you see. The job page shows each step and links the run on GitHub. The Actions tab of the repository also holds every run with its log. You can cancel a job while it waits in the queue and during the build. A failed build shows "The build failed in GitHub Actions. Open the run to read the log, fix the repository, then deploy again." A build that does not finish shows "GitHub Actions did not start or finish the build within 30 minutes. Nothing was deployed. Deploy again, or open the Actions tab of the repository." See The build failed or did not finish.
Whose allowance it uses. The build uses the GitHub Actions allowance of the repository owner. Before the first build, the repository step of the create-site wizard says: "Builds run on GitHub Actions in the repository. GitHub Free gives the repository owner USD 12 of usage a month and 500 MB of artifact storage. GitHub charges the owner for more."
The two workflow files. Fleet writes both files in the second commit of a new site, "Configure Fleet site", and never changes them afterwards. If one is missing, create it in the repository at the path shown, with exactly the text shown, and commit it to the default branch. If GitHub shows the file as disabled, enable it under Actions. To check a file, run git hash-object on it: the command prints the blob SHA listed with the file. Each file ends with one line break.
fleet-build.yml. Path .github/workflows/fleet-build.yml, blob SHA 6f0a60abeecf97a89d3679ff2631028ef6727376, 3534 bytes.
# Builds this EmDash site for Fleet for EmDash. It runs
# only when Fleet dispatches it, on the commit Fleet names, never on a push.
# It holds no secret and no Cloudflare credential: it bundles the Worker
# without uploading it (`wrangler versions upload --dry-run`) and keeps the
# bundle and the static output as an artifact for one day, which Fleet
# downloads and uploads to Cloudflare itself. The run uses this repository
# owner's GitHub Actions minutes. Keep the trigger, the inputs, the run-name,
# the concurrency group, the checkout and the artifact name as they are: Fleet
# relies on them. Fleet binds each build to the run
# it dispatched (a workflow_dispatch of this file on the dispatched branch,
# whose head is the commit it named) and downloads the artifact of that run
# only; a run started by anyone else is ignored.
# https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_dispatch
# https://developers.cloudflare.com/workers/wrangler/commands/workers/#versions-upload
name: fleet-build
run-name: fleet-build ${{ inputs.job_id }}
on:
workflow_dispatch:
inputs:
job_id:
description: The Fleet job this build belongs to
required: true
type: string
commit_sha:
description: The full SHA of the commit to build
required: true
type: string
permissions:
contents: read
concurrency: fleet-build
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
ASTRO_TELEMETRY_DISABLED: "1"
WRANGLER_SEND_METRICS: "false"
steps:
- name: Check the inputs
env:
JOB_ID: ${{ inputs.job_id }}
COMMIT_SHA: ${{ inputs.commit_sha }}
run: |
[[ "$JOB_ID" =~ ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ ]] || { echo "::error::job_id is not a job id"; exit 1; }
[[ "$COMMIT_SHA" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::commit_sha is not a full commit SHA"; exit 1; }
# GITHUB_SHA is the head of the branch the dispatch named. Fleet names
# that head and refuses a run whose head_sha differs, so a dispatch
# of another commit stops here instead of building it.
[[ "$COMMIT_SHA" == "$GITHUB_SHA" ]] || { echo "::error::commit_sha is not the head of the dispatched branch"; exit 1; }
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.commit_sha }}
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
# Node.js 26.13.0 bundles npm 11.20.0.
- run: npm install --global npm@12.2.2
- run: npm ci
# Fails on an unsigned or unattested @emdash-fleet/* package and warns
# for emdash and @emdash-cms/*.
- run: node scripts/audit-signatures.mjs
- run: npm run build
- run: npx wrangler versions upload --dry-run --outfile fleet-bundle/upload-form
# Two paths, so the artifact's root is the repository: fleet-bundle/ and
# dist/client/, with the hidden .assetsignore Fleet honours as Wrangler does.
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: fleet-bundle-${{ inputs.job_id }}
path: |
fleet-bundle/
dist/client/
retention-days: 1
if-no-files-found: error
include-hidden-files: truefleet-update.yml. Path .github/workflows/fleet-update.yml, blob SHA 75d97ddb5cf7fb6094f2a5cbc1fcd65dc7215f41, 7839 bytes.
# Prepares an EmDash or plugin update of this site for Fleet for EmDash. It
# runs only when Fleet dispatches it, installs the exact version Fleet names
# on the latest commit of the branch Fleet dispatched, and keeps the changed
# files as an artifact for one day: the entry `changes` holds `git status --porcelain=v1 -z
# --untracked-files=all` and each changed file that still exists is stored as
# `files/<path>`. Fleet checks the list and commits the files itself; this
# workflow writes nothing to the repository, holds no secret and runs nothing
# on the live site. The run uses this repository owner's GitHub Actions
# minutes. Keep the trigger, the inputs, the run-name, the concurrency group,
# the checkout and the artifact name as they are: Fleet relies on them. Fleet
# binds each update to the run it dispatched (a
# workflow_dispatch of this file on the dispatched branch) and accepts from its
# artifact only changes to package.json and package-lock.json.
# https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_dispatch
# https://git-scm.com/docs/git-status#_porcelain_format_version_1
name: fleet-update
run-name: fleet-update ${{ inputs.job_id }}
on:
workflow_dispatch:
inputs:
job_id:
description: The Fleet job this update belongs to
required: true
type: string
kind:
description: plugin or core
required: true
type: string
package:
description: The npm package to update; emdash for a core update
required: true
type: string
version:
description: The exact version to install
required: true
type: string
permissions:
contents: read
# One update at a time in this repository and never a cancelled run: a second
# dispatch waits for the first.
concurrency: fleet-update
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
ASTRO_TELEMETRY_DISABLED: "1"
steps:
- name: Check the inputs
env:
JOB_ID: ${{ inputs.job_id }}
KIND: ${{ inputs.kind }}
PACKAGE: ${{ inputs.package }}
VERSION: ${{ inputs.version }}
run: |
# The regular expression semver.org suggests for a version.
semver='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$'
name='^(@[a-z0-9][a-z0-9._-]*/)?[a-z0-9][a-z0-9._-]*$'
[[ "$JOB_ID" =~ ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ ]] || { echo "::error::job_id is not a job id"; exit 1; }
[[ "$KIND" == plugin || "$KIND" == core ]] || { echo "::error::kind is neither plugin nor core"; exit 1; }
[[ "$PACKAGE" =~ $name ]] || { echo "::error::package is not an npm package name"; exit 1; }
[[ "$VERSION" =~ $semver ]] || { echo "::error::version is not an exact version"; exit 1; }
[[ "$KIND" == plugin || "$PACKAGE" == emdash ]] || { echo "::error::a core update names the package emdash"; exit 1; }
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
# Node.js 26.13.0 bundles npm 11.20.0.
- run: npm install --global npm@12.2.2
# A core update moves emdash and @emdash-cms/cloudflare together, and
# @emdash-cms/cloudflare names emdash as an exact peer, so npm cannot
# install either package while package-lock.json still holds the other
# at the earlier version (ERESOLVE). The core branch sets both exact
# versions in package.json, removes from package-lock.json the entries
# of the EmDash packages (emdash, every @emdash-cms/ package and
# @cloudflare/kumo, the design system @emdash-cms/admin pins) with every
# package nested under them, keeping the file's indentation, and runs
# npm install, which resolves those packages again and keeps every other
# locked version. Leaving the nested entries made npm install drop them
# when the version did not change, and npm ci then refused the lockfile.
# https://docs.npmjs.com/cli/v11/configuring-npm/package-lock-json
- name: Install the update
env:
KIND: ${{ inputs.kind }}
PACKAGE: ${{ inputs.package }}
VERSION: ${{ inputs.version }}
run: |
case "$KIND" in
plugin) npm install "$PACKAGE@$VERSION" --save-exact ;;
core)
node --input-type=module -e '
import { readFileSync, writeFileSync } from "node:fs";
const version = process.env.VERSION;
const indentOf = (text) => /^[ \t]+/m.exec(text)?.[0] ?? "\t";
const pkgText = readFileSync("package.json", "utf8");
const pkg = JSON.parse(pkgText);
for (const name of ["emdash", "@emdash-cms/cloudflare"]) {
const group = ["dependencies", "devDependencies"].find((key) => pkg[key]?.[name] !== undefined);
if (group === undefined) { console.error(`::error::package.json does not depend on ${name}`); process.exit(1); }
pkg[group][name] = version;
}
writeFileSync("package.json", JSON.stringify(pkg, null, indentOf(pkgText)) + "\n");
const lockText = readFileSync("package-lock.json", "utf8");
const lock = JSON.parse(lockText);
const emdash = /(^|\/)node_modules\/(emdash|@emdash-cms\/[^/]+|@cloudflare\/kumo)(\/|$)/;
for (const path of Object.keys(lock.packages ?? {})) if (emdash.test(path)) delete lock.packages[path];
writeFileSync("package-lock.json", JSON.stringify(lock, null, indentOf(lockText)) + "\n");
'
npm install
;;
esac
# A rename lists the new path, then the original in the next NUL field,
# which is skipped. A listed path that no longer exists is not copied.
# npm install changes package.json and package-lock.json and nothing else
# that git tracks (node_modules/ is ignored): any other path means an
# install script wrote into the repository, and the run fails before
# anything is stored. Fleet checks the list again before it commits.
- name: Collect the changed files
run: |
out="$RUNNER_TEMP/fleet-update"
mkdir -p "$out/files"
git status --porcelain=v1 -z --untracked-files=all > "$out/changes"
original=false
while IFS= read -r -d '' entry; do
if [[ "$original" == true ]]; then original=false; continue; fi
status="${entry:0:2}"
path="${entry:3}"
[[ "$status" == *R* || "$status" == *C* ]] && original=true
case "$path" in package.json|package-lock.json) ;; *) echo "::error::$path changed; an update changes package.json and package-lock.json only"; exit 1 ;; esac
if [[ -L "$path" ]]; then echo "::error::$path is a symbolic link"; exit 1; fi
if [[ -f "$path" ]]; then
mkdir -p "$out/files/$(dirname -- "$path")"
cp -- "$path" "$out/files/$path"
fi
done < "$out/changes"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: fleet-update-${{ inputs.job_id }}
path: ${{ runner.temp }}/fleet-update/
retention-days: 1
if-no-files-found: error
include-hidden-files: trueRules and limits
- GitHub counts the allowance as money, not minutes, so Fleet promises no number of builds a month. All artifacts of the repository share the 500 MB of artifact storage.
- Standard runners in public repositories are free. Fleet creates every new repository as private, so a new site counts against the allowance.
- Without a payment method, GitHub blocks further usage once the included amount is used. Fleet shows no separate state for that, and the build ends with one of the messages above.
- An account runs a limited number of builds at once and per hour. See the limits reference.
- A repository whose workflow file differs from the one Fleet wrote still deploys. Fleet shows a warning with a link to the file.
- Fleet writes the two workflow files once, in the second commit of a new site, and never changes a path under
.github/workflowsafterwards. To restore a missing file, add it again with the text under The two workflow files, or enable a disabled one under Actions in GitHub. - GitHub documents the allowance in GitHub Actions billing and usage included in each plan.