Skip to content

Commit 407c0e9

Browse files
killerappclaude
andcommitted
ci: Add GitHub Actions for automated Cloudflare Pages deployment
- Create deploy.yml workflow for main branch deployments - Add preview.yml workflow for PR preview deployments - Configure GitHub secrets for Cloudflare API access - Add deployment status badges to README - Remove manual deploy script from package.json Now deployments will automatically trigger on: - Push to main branch - Pull request creation/updates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 8abfc38 commit 407c0e9

File tree

5 files changed

+138
-2
lines changed

5 files changed

+138
-2
lines changed

.claude/settings.local.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"Bash(npx shadcn@latest add \"https://magicui.design/r/magic-card\")",
99
"Bash(npm run build:*)",
1010
"Bash(npm run dev:*)",
11-
"Bash(git add:*)"
11+
"Bash(git add:*)",
12+
"Bash(npx wrangler pages deployment list:*)",
13+
"Bash(npx wrangler pages deploy:*)",
14+
"Bash(gh secret set:*)"
1215
],
1316
"deny": [],
1417
"ask": []

.github/workflows/deploy.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Deploy to Cloudflare Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Build project
26+
run: npm run build
27+
28+
- name: Deploy to Cloudflare Pages
29+
env:
30+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
31+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
32+
run: |
33+
npx wrangler pages deploy ./out \
34+
--project-name=learn-semver \
35+
--commit-hash=${{ github.sha }} \
36+
--commit-message="${{ github.event.head_commit.message }}" \
37+
--branch=${{ github.ref_name }}
38+
39+
- name: Comment deployment URL
40+
if: github.event_name == 'push'
41+
run: |
42+
echo "🚀 Deployed to Cloudflare Pages"
43+
echo "Preview: https://${{ github.sha }}.learn-semver.pages.dev"
44+
echo "Production: https://semver.agenticinsights.com"

.github/workflows/preview.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Deploy Preview to Cloudflare Pages
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
deploy-preview:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
pull-requests: write
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Build project
27+
run: npm run build
28+
29+
- name: Deploy preview to Cloudflare Pages
30+
id: deploy
31+
env:
32+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
33+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
34+
run: |
35+
OUTPUT=$(npx wrangler pages deploy ./out \
36+
--project-name=learn-semver \
37+
--commit-hash=${{ github.event.pull_request.head.sha }} \
38+
--commit-message="PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" \
39+
--branch=pr-${{ github.event.pull_request.number }})
40+
41+
# Extract deployment URL from output
42+
DEPLOYMENT_URL=$(echo "$OUTPUT" | grep -oP 'https://[a-z0-9]+\.learn-semver\.pages\.dev' | head -1)
43+
echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT
44+
45+
- name: Comment on PR
46+
uses: actions/github-script@v7
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
script: |
50+
const deployment_url = '${{ steps.deploy.outputs.deployment_url }}';
51+
const comment = `### 🚀 Preview Deployment Ready!
52+
53+
Your changes have been deployed to Cloudflare Pages:
54+
55+
🔗 **Preview URL**: ${deployment_url}
56+
57+
This preview will be updated automatically as you push new commits to this PR.`;
58+
59+
// Find existing comment
60+
const { data: comments } = await github.rest.issues.listComments({
61+
owner: context.repo.owner,
62+
repo: context.repo.repo,
63+
issue_number: context.issue.number,
64+
});
65+
66+
const botComment = comments.find(comment =>
67+
comment.user.type === 'Bot' &&
68+
comment.body.includes('Preview Deployment Ready')
69+
);
70+
71+
if (botComment) {
72+
// Update existing comment
73+
await github.rest.issues.updateComment({
74+
owner: context.repo.owner,
75+
repo: context.repo.repo,
76+
comment_id: botComment.id,
77+
body: comment
78+
});
79+
} else {
80+
// Create new comment
81+
await github.rest.issues.createComment({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
issue_number: context.issue.number,
85+
body: comment
86+
});
87+
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Semantic Version Visualizer
22

3+
[![Deploy to Cloudflare Pages](https://github.com/killerapp/learn-semver/actions/workflows/deploy.yml/badge.svg)](https://github.com/killerapp/learn-semver/actions/workflows/deploy.yml)
4+
[![Live Demo](https://img.shields.io/badge/demo-live-brightgreen)](https://semver.agenticinsights.com)
5+
36
An interactive tool to learn and understand [Semantic Versioning](https://semver.org) through visual demonstrations.
47

58
🚀 **Live Demo**: [semver.agenticinsights.com](https://semver.agenticinsights.com)

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"dev": "next dev --turbopack -p 30020",
77
"build": "next build",
88
"preview": "wrangler pages dev ./out",
9-
"deploy": "npm run build && wrangler pages deploy ./out --project-name=learn-semver",
109
"start": "next start",
1110
"lint": "next lint"
1211
},

0 commit comments

Comments
 (0)