Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: [Cloudflare Pages] automation to deploy website to Cloudflare Pages
Scripts are very simple: - On trigger to build main/latest, call Deploy Hook on Cloudflare Pages. - On release, copy "main" to "production". Cloudflare Pages takes care of the rest.
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Deploy on Cloudflare Pages (Production) | ||
|
||
on: | ||
repository_dispatch: | ||
types: | ||
- publish_latest_tag | ||
|
||
concurrency: cfp-production | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Trigger deploy hook | ||
run: | | ||
curl -X POST ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_HOOK_PRODUCTION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Deploy on Cloudflare Pages (Staging) | ||
|
||
on: | ||
repository_dispatch: | ||
types: | ||
- publish_main | ||
|
||
concurrency: cfp-staging | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Trigger deploy hook | ||
run: | | ||
curl -X POST ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_HOOK_STAGING }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: New Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
new_release: | ||
name: New Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Get SHA of tag | ||
id: tag_sha | ||
uses: octokit/request-action@v2.x | ||
with: | ||
route: GET /repos/{repository}/commits/{tag}?per_page=1 | ||
repository: ${{ github.repository }} | ||
tag: ${{ github.event.release.tag_name }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Copy main branch to production branch | ||
uses: octokit/request-action@v2.x | ||
with: | ||
route: PATCH /repos/{repository}/git/refs/heads/production | ||
repository: ${{ github.repository }} | ||
sha: ${{ fromJson(steps.tag_sha.outputs.data).sha }} | ||
force: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |