From a7fceb747846e54306a752d181626874cb3cf545 Mon Sep 17 00:00:00 2001 From: kaffa Date: Sat, 28 Mar 2026 06:47:10 +0000 Subject: [PATCH] =?UTF-8?q?refactor:=20wrangler=20=E2=86=92=20rclone=20?= =?UTF-8?q?=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/deploy.yml | 56 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index a88cd5e..016e026 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -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"