Skip to main content

Running Github Actions After Cloudflare Pages Deploy

· 2 min read
Nate Totten

Unfortunately, the Cloudflare Pages integration for Github doesn't support Github Deployment status, this means you can't trigger actions on deployment_status. deployment_status is the ideal event to use when running tests after a deployment as the event details include the URL. This is how we run tests on Vercel deployments after they are finished.

Fortunately, there is a pretty hacky way to do this with Cloudflare Pages. The check_run event is fired by the pages integration. The check run provides an output object in the event. Unfortunately, the contents is meant for human readable output. It looks like this:

"output": {
"annotations_count": 0,
"annotations_url": "",
"summary": "<table><tr><td><strong>Latest commit:</strong> </td><td>\n<code>be76cc6</code>\n</td></tr>\n<tr><td><strong>Status:</strong></td><td>&nbsp;✅&nbsp; Deploy successful!</td></tr>\n<tr><td><strong>Preview URL:</strong></td><td>\n<a href=''></a>\n</td></tr>\n</table>\n\n[View logs](\n",
"text": null,
"title": "Deployed successfully"

With a little bit of scripting though it is possible to extract the URL from that summary string. I used grep and cut to do that with the following:

echo "${{ github.event.check_run.output.summary }}" | grep -o "href\=.*>https" | cut -c 7-43

Note the 7-43 at the end is the start index and end index of the string to pull from the grep result. Those numbers need to be adjusted depending on the length of your deployment url name.

To use the value, just extract it into an environment variable and you can use it later steps in your action.

types: [completed]

name: Test
runs-on: ubuntu-latest

- uses: actions/[email protected]
- name: Get Deployment URL
run: echo "DEPLOYMENT_URL=$(echo "${{ github.event.check_run.output.summary }}" | grep -o "href\=.*>https" | cut -c 7-43)" >> $GITHUB_ENV
- run: echo $DEPLOYMENT_URL

Not a super elegant solution, but it works. At least until Cloudflare changes that status message.