Files
cf-multisite/.gitea/workflows/deploy.yml
kaffa de7c042e2c
All checks were successful
TypeScript CI / build (push) Successful in 31s
Deploy to R2 / deploy (push) Successful in 48s
refactor: AWS CLI → wrangler R2로 배포 속도 개선
2026-03-28 06:20:14 +00:00

52 lines
1.4 KiB
YAML

name: Deploy to R2
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install wrangler
run: npm install -g wrangler
- name: Upload to R2
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
R2_BUCKET: multisite-bucket
CUSTOMER_ID: ${{ github.repository_name }}
run: |
SOURCE_DIR="."
if [ -d "public" ]; then
SOURCE_DIR="public"
fi
echo "Deploying $CUSTOMER_ID from $SOURCE_DIR"
find "$SOURCE_DIR" -type f \
-not -path '*/.git/*' \
-not -path '*/.gitea/*' \
-not -name '*.md' \
-not -name 'README*' \
-not -name 'package*.json' \
-not -name 'wrangler.toml' \
-not -name '.rebuild' \
-not -name '.gitignore' \
-not -name 'LICENSE' | while read file; do
key="sites/${CUSTOMER_ID}/${file#$SOURCE_DIR/}"
echo " uploading: $key"
wrangler r2 object put "${R2_BUCKET}/${key}" --file="$file" --content-type="$(file -b --mime-type $file)"
done
echo "Deployed to: https://${CUSTOMER_ID}.actions.it.com"