refactor: wrangler → rclone 통일
This commit is contained in:
@@ -11,41 +11,39 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Install rclone
|
||||||
uses: actions/setup-node@v4
|
run: curl -s https://rclone.org/install.sh | sudo bash
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
|
|
||||||
- name: Install wrangler
|
- name: Deploy to R2
|
||||||
run: npm install -g wrangler
|
|
||||||
|
|
||||||
- name: Upload to R2
|
|
||||||
env:
|
env:
|
||||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
R2_ACCESS_KEY: ${{ secrets.R2_ACCESS_KEY }}
|
||||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
|
||||||
|
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
|
||||||
R2_BUCKET: multisite-bucket
|
R2_BUCKET: multisite-bucket
|
||||||
CUSTOMER_ID: ${{ github.repository_name }}
|
|
||||||
run: |
|
run: |
|
||||||
|
CUSTOMER_ID="${GITHUB_REPOSITORY##*/}"
|
||||||
SOURCE_DIR="."
|
SOURCE_DIR="."
|
||||||
if [ -d "public" ]; then
|
if [ -d "public" ]; then SOURCE_DIR="public"; fi
|
||||||
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"
|
echo "Deploying $CUSTOMER_ID from $SOURCE_DIR"
|
||||||
|
rclone sync "$SOURCE_DIR" "r2:${R2_BUCKET}/sites/${CUSTOMER_ID}/" \
|
||||||
find "$SOURCE_DIR" -type f \
|
--exclude ".git/**" --exclude ".gitea/**" \
|
||||||
-not -path '*/.git/*' \
|
--exclude "*.md" --exclude "README*" \
|
||||||
-not -path '*/.gitea/*' \
|
--exclude ".rebuild" --exclude ".gitignore" --exclude "LICENSE" \
|
||||||
-not -name '*.md' \
|
--exclude "package*.json" --exclude "wrangler.toml" \
|
||||||
-not -name 'README*' \
|
--exclude "node_modules/**" --exclude "scripts/**" --exclude "src/**" \
|
||||||
-not -name 'package*.json' \
|
-v
|
||||||
-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"
|
echo "Deployed to: https://${CUSTOMER_ID}.actions.it.com"
|
||||||
|
|||||||
Reference in New Issue
Block a user