refactor: wrangler → rclone 통일
Some checks failed
TypeScript CI / build (push) Successful in 29s
Deploy to R2 / deploy (push) Has been cancelled

This commit is contained in:
2026-03-28 06:47:10 +00:00
parent de7c042e2c
commit a7fceb7478

View File

@@ -11,41 +11,39 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install rclone
run: curl -s https://rclone.org/install.sh | sudo bash
- name: Install wrangler
run: npm install -g wrangler
- name: Upload to R2
- name: Deploy to R2
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
R2_ACCESS_KEY: ${{ secrets.R2_ACCESS_KEY }}
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
R2_BUCKET: multisite-bucket
CUSTOMER_ID: ${{ github.repository_name }}
run: |
CUSTOMER_ID="${GITHUB_REPOSITORY##*/}"
SOURCE_DIR="."
if [ -d "public" ]; then
SOURCE_DIR="public"
fi
if [ -d "public" ]; then SOURCE_DIR="public"; fi
mkdir -p ~/.config/rclone
cat > ~/.config/rclone/rclone.conf << EOF2
[r2]
type = s3
provider = Cloudflare
access_key_id = ${R2_ACCESS_KEY}
secret_access_key = ${R2_SECRET_KEY}
endpoint = ${R2_ENDPOINT}
acl = private
no_check_bucket = true
EOF2
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
rclone sync "$SOURCE_DIR" "r2:${R2_BUCKET}/sites/${CUSTOMER_ID}/" \
--exclude ".git/**" --exclude ".gitea/**" \
--exclude "*.md" --exclude "README*" \
--exclude ".rebuild" --exclude ".gitignore" --exclude "LICENSE" \
--exclude "package*.json" --exclude "wrangler.toml" \
--exclude "node_modules/**" --exclude "scripts/**" --exclude "src/**" \
-v
echo "Deployed to: https://${CUSTOMER_ID}.actions.it.com"