-
Notifications
You must be signed in to change notification settings - Fork 2.4k
43 lines (37 loc) · 1.17 KB
/
deploy.yml
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
name: Deploy Worker
on:
workflow_dispatch:
repository_dispatch:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '21'
- name: Install dependencies
run: npm install
- name: Install wrangler
run: npm install -g wrangler
- name: Check and Create R2 Bucket
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
run: |
BUCKET_NAME="sublink-worker"
if ! wrangler r2 bucket list | grep -q "$BUCKET_NAME"; then
echo "Bucket $BUCKET_NAME does not exist. Creating..."
wrangler r2 bucket create "$BUCKET_NAME"
echo "Bucket $BUCKET_NAME created successfully."
else
echo "Bucket $BUCKET_NAME already exists. Skipping creation."
fi
- name: Deploy to Cloudflare Workers
uses: cloudflare/wrangler-action@2.0.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}