Skip to content

Commit e8348d9

Browse files
committed
feat: Add production deployment GitHub Actions workflow
- Create deploy.yml for automatic production deployments - Update preview.yml to include deployment URL and commit comment - Add comment generation for deployment links in both workflows - Update wrangler.toml with a preview environment comment
1 parent 8ad9c4b commit e8348d9

3 files changed

Lines changed: 76 additions & 3 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy Production
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
name: Deploy Production
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: 9
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "22"
23+
cache: "pnpm"
24+
25+
- name: Install dependencies
26+
run: pnpm install
27+
28+
- name: Deploy to Cloudflare Workers
29+
id: deploy-production
30+
uses: cloudflare/wrangler-action@v3
31+
with:
32+
apiToken: ${{ secrets.CF_API_TOKEN }}
33+
command: deploy
34+
35+
- name: Get deployment URL
36+
id: deployment-url
37+
run: |
38+
PRODUCTION_URL=$(echo '${{ steps.deploy-production.outputs.deployedUrl }}')
39+
if [ -z "$PRODUCTION_URL" ]; then
40+
PRODUCTION_URL="https://github-achievements-api.wangrunlin.workers.dev"
41+
fi
42+
echo "url=$PRODUCTION_URL" >> $GITHUB_OUTPUT
43+
44+
- name: Comment on commit
45+
uses: peter-evans/commit-comment@v2
46+
with:
47+
body: |
48+
🚀 Production deployment is ready!
49+
50+
🔗 [Production Link](${{ steps.deployment-url.outputs.url }})
51+
52+
Branch: ${{ github.ref_name }}
53+
Commit: ${{ github.sha }}

.github/workflows/preview.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,28 @@ jobs:
2626
run: pnpm install
2727

2828
- name: Deploy to Cloudflare Workers with Preview
29+
id: deploy-preview
2930
uses: cloudflare/wrangler-action@v3
3031
with:
3132
apiToken: ${{ secrets.CF_API_TOKEN }}
3233
command: deploy --env preview
33-
env:
34-
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
34+
35+
- name: Get deployment URL
36+
id: deployment-url
37+
run: |
38+
PREVIEW_URL=$(echo '${{ steps.deploy-preview.outputs.deployedUrl }}')
39+
if [ -z "$PREVIEW_URL" ]; then
40+
PREVIEW_URL="https://github-achievements-api-preview.wangrunlin.workers.dev"
41+
fi
42+
echo "url=$PREVIEW_URL" >> $GITHUB_OUTPUT
43+
44+
- name: Comment on commit
45+
uses: peter-evans/commit-comment@v2
46+
with:
47+
body: |
48+
🚀 Preview deployment is ready!
49+
50+
🔗 [Preview Link](${{ steps.deployment-url.outputs.url }})
51+
52+
Branch: ${{ github.ref_name }}
53+
Commit: ${{ github.sha }}

wrangler.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ main = "src/index.ts"
33
compatibility_date = "2025-02-27"
44

55
[env.preview]
6-
name = "github-achievements-api-preview"
6+
name = "github-achievements-api-preview"
7+
# Asegúrate de que el entorno de vista previa tenga la misma configuración que el entorno principal

0 commit comments

Comments
 (0)