fix: add r2 binding to github action and update readme
This commit is contained in:
parent
4f61077ca9
commit
9b84f4fdd8
4 changed files with 44 additions and 10 deletions
12
.github/workflows/deploy-dev.yaml
vendored
12
.github/workflows/deploy-dev.yaml
vendored
|
|
@ -56,6 +56,18 @@ jobs:
|
||||||
- name: Replace D1_DATABASE_ID_DEV in wrangler.toml
|
- name: Replace D1_DATABASE_ID_DEV in wrangler.toml
|
||||||
run: sed -i "s/\${D1_DATABASE_ID_DEV}/${{ secrets.D1_DATABASE_ID_DEV }}/g" wrangler.toml
|
run: sed -i "s/\${D1_DATABASE_ID_DEV}/${{ secrets.D1_DATABASE_ID_DEV }}/g" wrangler.toml
|
||||||
|
|
||||||
|
- name: Enable R2 binding when R2_NAME_DEV is provided
|
||||||
|
if: secrets.R2_NAME_DEV != ''
|
||||||
|
env:
|
||||||
|
R2_NAME_DEV: ${{ secrets.R2_NAME_DEV }}
|
||||||
|
run: |
|
||||||
|
echo "🔧 Enabling dev R2 bucket binding for ${R2_NAME_DEV}"
|
||||||
|
cat <<EOF >> wrangler.toml
|
||||||
|
[[env.dev.r2_buckets]]
|
||||||
|
binding = "ATTACHMENTS_BUCKET"
|
||||||
|
bucket_name = "${R2_NAME_DEV}"
|
||||||
|
EOF
|
||||||
|
|
||||||
- name: Apply D1 database migrations (dev)
|
- name: Apply D1 database migrations (dev)
|
||||||
env:
|
env:
|
||||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
|
|
|
||||||
12
.github/workflows/push-cloudflare.yaml
vendored
12
.github/workflows/push-cloudflare.yaml
vendored
|
|
@ -67,6 +67,18 @@ jobs:
|
||||||
- name: Replace D1_DATABASE_ID in wrangler.toml
|
- name: Replace D1_DATABASE_ID in wrangler.toml
|
||||||
run: sed -i "s/\${D1_DATABASE_ID}/${{ secrets.D1_DATABASE_ID }}/g" wrangler.toml
|
run: sed -i "s/\${D1_DATABASE_ID}/${{ secrets.D1_DATABASE_ID }}/g" wrangler.toml
|
||||||
|
|
||||||
|
- name: Enable R2 binding when R2_NAME is provided
|
||||||
|
if: secrets.R2_NAME != ''
|
||||||
|
env:
|
||||||
|
R2_NAME: ${{ secrets.R2_NAME }}
|
||||||
|
run: |
|
||||||
|
echo "🔧 Enabling R2 bucket binding for ${R2_NAME}"
|
||||||
|
cat <<EOF >> wrangler.toml
|
||||||
|
[[r2_buckets]]
|
||||||
|
binding = "ATTACHMENTS_BUCKET"
|
||||||
|
bucket_name = "${R2_NAME}"
|
||||||
|
EOF
|
||||||
|
|
||||||
- name: Apply D1 database migrations
|
- name: Apply D1 database migrations
|
||||||
env:
|
env:
|
||||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
|
|
|
||||||
15
README.md
15
README.md
|
|
@ -189,17 +189,14 @@ Add the following secrets to your GitHub repository (`Settings > Secrets and var
|
||||||
|
|
||||||
If you want to use file attachments:
|
If you want to use file attachments:
|
||||||
|
|
||||||
1. **Create R2 buckets:**
|
1. **Create R2 buckets in Cloudflare Dashboard before running the action:**
|
||||||
- Log in to [Cloudflare Dashboard](https://dash.cloudflare.com/)
|
|
||||||
- Go to **Storage & databases** → **R2** → **Create bucket**
|
- Go to **Storage & databases** → **R2** → **Create bucket**
|
||||||
- Create buckets named `warden-attachments`
|
- Create a production bucket (e.g., `warden-attachments`)
|
||||||
|
|
||||||
2. **Add R2 bindings:**
|
2. **Add the bucket names as GitHub Action secrets:**
|
||||||
- Go to **Workers & Pages** → Select your `warden-worker`
|
- `R2_NAME` → production bucket name
|
||||||
- Click **Settings** → **Bindings**
|
|
||||||
- Click **Add binding** → **R2 bucket**
|
The workflows will auto-append the `ATTACHMENTS_BUCKET` binding into `wrangler.toml` when these secrets are present - no manual binding in the Cloudflare console is required.
|
||||||
- Variable name: `ATTACHMENTS_BUCKET`
|
|
||||||
- R2 bucket: `warden-attachments`
|
|
||||||
|
|
||||||
4. **Manually trigger the `Build` Action** from the GitHub Actions tab in your repository
|
4. **Manually trigger the `Build` Action** from the GitHub Actions tab in your repository
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,4 +85,17 @@ migrations_dir = "migrations"
|
||||||
# Uncomment and configure this section to enable file attachments
|
# Uncomment and configure this section to enable file attachments
|
||||||
# [[env.dev.r2_buckets]]
|
# [[env.dev.r2_buckets]]
|
||||||
# binding = "ATTACHMENTS_BUCKET"
|
# binding = "ATTACHMENTS_BUCKET"
|
||||||
# bucket_name = "warden-attachments-dev"
|
# bucket_name = "warden-attachments-dev"
|
||||||
|
|
||||||
|
# logs
|
||||||
|
[env.dev.observability]
|
||||||
|
[env.dev.observability.logs]
|
||||||
|
enabled = true
|
||||||
|
head_sampling_rate = 1
|
||||||
|
invocation_logs = true
|
||||||
|
persist = true
|
||||||
|
|
||||||
|
[env.dev.observability.traces]
|
||||||
|
enabled = false
|
||||||
|
persist = true
|
||||||
|
head_sampling_rate = 1
|
||||||
Loading…
Reference in a new issue