Skip to content

Commit 4358c7a

Browse files
committed
ci: add deploy script and GitHub Actions workflow for Cloudflare Pages
1 parent d1c12d8 commit 4358c7a

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

.github/workflows/deploy.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and Deploy to Cloudflare Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build-and-deploy:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
deployments: write
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 22
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Build
33+
run: npm run build
34+
35+
- name: Deploy to Cloudflare Pages
36+
if: github.ref == 'refs/heads/main'
37+
uses: cloudflare/wrangler-action@v3
38+
with:
39+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
40+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
41+
command: pages deploy dist --project-name=diegosaid

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"build": "tsc -b && vite build",
1515
"lint": "eslint .",
1616
"preview": "vite preview",
17-
"deploy": "npm run build && wrangler pages deploy dist --project-name=diegosaid"
17+
"deploy": "npm run build && wrangler pages deploy dist --project-name=diegosaid",
18+
"deploy:prod": "git push origin main && npm run deploy"
1819
},
1920
"dependencies": {
2021
"@gsap/react": "^2.1.2",

0 commit comments

Comments
 (0)