50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
name: Deploy to R2
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install rclone
|
|
run: curl -s https://rclone.org/install.sh | sudo bash
|
|
|
|
- name: Deploy to R2
|
|
env:
|
|
R2_ACCESS_KEY: ${{ secrets.R2_ACCESS_KEY }}
|
|
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
|
|
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
|
|
R2_BUCKET: multisite-bucket
|
|
run: |
|
|
CUSTOMER_ID="${GITHUB_REPOSITORY##*/}"
|
|
SOURCE_DIR="."
|
|
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"
|
|
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"
|