Actions
Actions are buttons that start a GitHub Actions workflow. Use them to rebuild the site on demand, regenerate a page, optimise images or anything else you've automated. The workflow does the work; SP CMS starts it, passes it context and tracks the run. For the editor's side, see run actions.
GitHub Actions must be enabled on the repository.
Add a deploy button
First, create the workflow. It must accept a payload input:
name: Deploy
on:
workflow_dispatch:
inputs:
payload:
description: SP CMS context as JSON
required: true
type: string
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Run your deploy command here"Then add the button to .pages.yml:
actions:
- name: deploy
label: Deploy site
workflow: deploy.ymlTo try it, choose Deploy site in the sidebar and confirm. Follow the run on the Actions page, under Admin in the sidebar.
Where buttons appear
Where you define an action decides where its button shows up and what it acts on:
For example, add this action to a collection to show a button on each entry:
content:
- name: posts
type: collection
path: src/content/posts
actions:
- name: preview
label: Preview
workflow: preview.yml
scope: entryKeys
Ask for inputs
fields adds a form to the confirmation dialog. Values arrive in payload.inputs.
actions:
- name: deploy
label: Deploy
workflow: deploy.yml
fields:
- name: environment
label: Environment
type: select
required: true
default: staging
options:
- { label: Staging, value: staging }
- { label: Production, value: production }
- name: clear_cache
label: Clear CDN cache
type: checkboxWhen an action has fields, the dialog is shown even with confirm: false.
The payload
The workflow receives one JSON string in inputs.payload:
{
"source": "pages-cms",
"action": { "name": "deploy", "label": "Deploy", "cancelable": true },
"repository": {
"owner": "SeymourpowellLtd",
"repo": "website",
"ref": "main",
"workflowRef": "main",
"sha": "abc123…"
},
"triggeredAt": "2026-03-30T12:00:00.000Z",
"triggeredBy": {
"userId": "…",
"name": "Sam Lee",
"email": "sam@example.com",
"githubUsername": "samlee",
"image": null
},
"context": {
"type": "entry",
"name": "posts",
"path": "src/content/posts/hello.md",
"data": {}
},
"inputs": { "environment": "staging", "clear_cache": true }
}source is a fixed value. context describes where the action was run from: repository, collection, entry, file or media, with the content or library name and the path. context.data holds extra details from the page, such as a collection's label. githubUsername is null or missing for people without a linked GitHub account. Reruns also include "triggerType": "rerun" and rerunOfActionRunId.
Read values with fromJSON:
- run: ./deploy.sh "$ENVIRONMENT"
env:
ENVIRONMENT: ${{ fromJSON(inputs.payload).inputs.environment }}Treat the whole payload as user input, including filenames, form values and the name of the person who ran it. In a shell step, pass expressions through env and quote the shell variable as above. GitHub substitutes expressions placed directly in run before the shell runs the script.
Who can run actions
Managers, people signed in with GitHub who have write access to the repository, and invited collaborators can run the actions in .pages.yml. Only managers can cancel a run (unless cancelable: false) or run it again.