Sample repository for a GitHub Actions workflow to deploy Preview
and Production
site builds on Cloudflare Pages or Netlify. Template site used here
- In the GitHub repository, create 2 secrets inside the repository
Settings
:CLOUDFLARE_ACCOUNT_ID
CLOUDFLARE_API_TOKEN
- In Cloudflare, create a Pages project with a name
$PROJECT_NAME
and default branch asmaster
. Project creation can be done using thewrangler
CLI provided by Cloudflare:wrangler pages project create
- In the GitHub repository, copy over the
cf-pages-*
files under.github/workflows
from this repository. - Edit the
projectName: 'diagram-chasing'
line near the bottom, replacingdiagram-chasing
with the Pages project name ($PROJECT_NAME
)
-
In Netlify, create a Site with a name
$SITE_NAME
. Site creation can be done using thenetlify
CLI provided by Netlify:netlify sites:create
-
In the GitHub repository, create 2 secrets inside the repository
Settings
:NETLIFY_AUTH_TOKEN
NETLIFY_SITE_ID
-
In the GitHub repository, copy over the
netlify-*
files under.github/workflows
from this repository. -
Replace the
baseURL
andanalyticsID
inpackage.json
with the Netlify URL and Plausible Analytics ID. Base URL corresponds to where the site is being deployed on Netlify, (no prefix likepreview--
).
- Go to the
Actions
section of the GitHub repository to view the configured workflows. Preview Deploy
workflow automatically runs on every commit tomaster
. Manual trigger can be done from theActions
section of the GitHub repository, or using thegh
CLIProduction Deploy
workflow needs to be manually triggered.
- Preview:
https://preview.$PROJECT_NAME.pages.dev
- Production:
https://$PROJECT_NAME.pages.dev
- Preview:
https://preview--$SITE_NAME.netlify.app
- Production:
https://$SITE_NAME.netlify.app
On the main site, create a _redirects
file to configure the required redirect.