Skip to content

Commit 0d5ccdd

Browse files
committed
ci: Update GitHub workflow to support multiple deployment environments
1 parent c9b8a5c commit 0d5ccdd

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

.github/workflows/deploy-with-wrangler.yml

+25-3
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,42 @@ name: Deploy to Cloudflare
22

33
on:
44
push:
5-
branches: [main]
5+
branches:
6+
- main
7+
- staging
8+
pull_request:
9+
branches:
10+
- staging
611

712
jobs:
813
deploy:
914
runs-on: ubuntu-latest
10-
name: Ship Ship Ship
15+
name: Deploy and Test
1116
steps:
1217
- name: Checkout Code
1318
uses: actions/checkout@v4
19+
20+
- name: Determine Environment
21+
id: env
22+
run: |
23+
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
24+
echo "WRANGLER_ENV=preview" >> $GITHUB_ENV
25+
echo "TEST_URL=https://aibtcdev-cache.PREVIEW_URL" >> $GITHUB_ENV
26+
elif [[ ${{ github.ref }} == 'refs/heads/staging' ]]; then
27+
echo "WRANGLER_ENV=staging" >> $GITHUB_ENV
28+
echo "TEST_URL=https://cache-staging.aibtc.dev" >> $GITHUB_ENV
29+
else
30+
echo "WRANGLER_ENV=production" >> $GITHUB_ENV
31+
echo "TEST_URL=https://cache.aibtc.dev" >> $GITHUB_ENV
32+
fi
33+
1434
- name: Deploy with Wrangler
1535
uses: cloudflare/wrangler-action@v3
1636
with:
1737
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
38+
environment: ${{ env.WRANGLER_ENV }}
39+
1840
- name: Test Endpoints (10s delay)
1941
run: |
2042
chmod +x tests/run_tests.sh
21-
./tests/run_tests.sh https://cache.aibtc.dev true
43+
./tests/run_tests.sh ${{ env.TEST_URL }} true

0 commit comments

Comments
 (0)