Skip to content

Commit 4417d5d

Browse files
authored
Add: [Cloudflare Pages] automation to deploy website to Cloudflare Pages (#227)
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.
1 parent e7264d6 commit 4417d5d

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Deploy on Cloudflare Pages (Production)
2+
3+
on:
4+
repository_dispatch:
5+
types:
6+
- publish_latest_tag
7+
8+
concurrency: cfp-production
9+
10+
jobs:
11+
deploy:
12+
name: Deploy
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Trigger deploy hook
17+
run: |
18+
curl -X POST ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_HOOK_PRODUCTION }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Deploy on Cloudflare Pages (Staging)
2+
3+
on:
4+
repository_dispatch:
5+
types:
6+
- publish_main
7+
8+
concurrency: cfp-staging
9+
10+
jobs:
11+
deploy:
12+
name: Deploy
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Trigger deploy hook
17+
run: |
18+
curl -X POST ${{ secrets.CLOUDFLARE_PAGES_DEPLOY_HOOK_STAGING }}

.github/workflows/release.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: New Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
new_release:
9+
name: New Release
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Get SHA of tag
14+
id: tag_sha
15+
uses: octokit/request-action@v2.x
16+
with:
17+
route: GET /repos/{repository}/commits/{tag}?per_page=1
18+
repository: ${{ github.repository }}
19+
tag: ${{ github.event.release.tag_name }}
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Copy main branch to production branch
24+
uses: octokit/request-action@v2.x
25+
with:
26+
route: PATCH /repos/{repository}/git/refs/heads/production
27+
repository: ${{ github.repository }}
28+
sha: ${{ fromJson(steps.tag_sha.outputs.data).sha }}
29+
force: true
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)