-
Notifications
You must be signed in to change notification settings - Fork 103
146 lines (126 loc) · 4.66 KB
/
deploy.yml
File metadata and controls
146 lines (126 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Deploy to Cloudflare
permissions:
contents: read
deployments: write
checks: write
on:
workflow_run:
workflows: ["Test"]
types:
- completed
branches: [main]
workflow_dispatch:
jobs:
deploy:
name: Deploy to Cloudflare
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
# pnpm/action-setup@v4
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda
name: Install pnpm
with:
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
# === BUILD AND DEPLOY CANARY WORKER ===
- name: Build
run: pnpm -w run build
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Deploy to Canary Worker
id: deploy_canary
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: packages/mcp-cloudflare
command: deploy --config wrangler.canary.jsonc
packageManager: pnpm
- name: Wait for Canary to Propagate
if: success()
run: |
echo "Waiting 30 seconds for canary deployment to propagate..."
sleep 30
# === SMOKE TEST CANARY ===
- name: Run Smoke Tests on Canary
id: canary_smoke_tests
if: success()
env:
PREVIEW_URL: https://sentry-mcp-canary.getsentry.workers.dev
run: |
echo "Running smoke tests against canary worker..."
cd packages/smoke-tests
pnpm test:ci
- name: Publish Canary Smoke Test Report
uses: mikepenz/action-junit-report@cf701569b05ccdd861a76b8607a66d76f6fd4857
if: always() && steps.canary_smoke_tests.outcome != 'skipped'
with:
report_paths: "packages/smoke-tests/tests.junit.xml"
check_name: "Canary Smoke Test Results"
fail_on_failure: false
# === DEPLOY PRODUCTION WORKER (only if canary tests pass) ===
- name: Deploy to Production Worker
id: deploy_production
if: steps.canary_smoke_tests.outcome == 'success'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: packages/mcp-cloudflare
command: deploy
packageManager: pnpm
- name: Wait for Production to Propagate
if: steps.deploy_production.outcome == 'success'
run: |
echo "Waiting 30 seconds for production deployment to propagate..."
sleep 30
# === SMOKE TEST PRODUCTION ===
- name: Run Smoke Tests on Production
id: production_smoke_tests
if: steps.deploy_production.outcome == 'success'
env:
PREVIEW_URL: https://mcp.sentry.dev
run: |
echo "Running smoke tests on production..."
cd packages/smoke-tests
pnpm test:ci
- name: Publish Production Smoke Test Report
uses: mikepenz/action-junit-report@cf701569b05ccdd861a76b8607a66d76f6fd4857
if: always() && steps.production_smoke_tests.outcome != 'skipped'
with:
report_paths: "packages/smoke-tests/tests.junit.xml"
check_name: "Production Smoke Test Results"
fail_on_failure: false
# === ROLLBACK IF PRODUCTION SMOKE TESTS FAIL ===
- name: Rollback Production on Smoke Test Failure
if: steps.production_smoke_tests.outcome == 'failure'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: packages/mcp-cloudflare
command: rollback
packageManager: pnpm
continue-on-error: true
- name: Fail Job if Production Smoke Tests Failed
if: steps.production_smoke_tests.outcome == 'failure'
run: |
echo "Production smoke tests failed - job failed after rollback"
exit 1