@@ -38,88 +38,77 @@ jobs:
3838 git commit -m "Deploy $GITHUB_SHA to gh-pages"
3939 git push --force --set-upstream origin gh-pages
4040
41- - name : Install and Configure s3cmd
41+ - name : Install and Configure rclone
4242 run : |
43- # Install s3cmd
44- pip install s3cmd
43+ # Install rclone
44+ curl https://rclone.org/ install.sh | sudo bash
4545
46- # Extract domain from endpoint URL (remove https:// if present)
47- ENDPOINT=$(echo "${{ secrets.S3_ENDPOINT_URL }}" | sed 's/https:\/\///')
48-
49- # Create s3cmd config file with MIME type settings
50- cat > ~/.s3cfg << EOF
51- [default]
52- access_key = ${{ secrets.S3_ACCESS_KEY }}
53- secret_key = ${{ secrets.S3_SECRET_KEY }}
54- host_base = ${ENDPOINT}
55- host_bucket = ${ENDPOINT}
56- use_https = True
57- check_ssl_certificate = False
58- check_ssl_hostname = False
59- # Enable verbose output and progress meter
60- verbose = True
61- progress_meter = True
62- # Enable proper MIME types detection
63- guess_mime_type = True
46+ # Configure rclone for S3 compatible storage
47+ mkdir -p ~/.config/rclone
48+ cat > ~/.config/rclone/rclone.conf << EOF
49+ [s3]
50+ type = s3
51+ provider = Other
52+ env_auth = false
53+ access_key_id = ${{ secrets.S3_ACCESS_KEY }}
54+ secret_access_key = ${{ secrets.S3_SECRET_KEY }}
55+ endpoint = ${{ secrets.S3_ENDPOINT_URL }}
56+ acl = public-read
57+ bucket_acl = public-read
58+ storage_class = STANDARD
59+ no_check_bucket = true
6460 EOF
6561
66- - name : Deploy to S3-compatible storage with s3cmd
62+ - name : Deploy to S3-compatible storage with rclone
6763 run : |
6864 # Navigate to where the built files are
6965 cd gh-pages
7066
7167 # Print info about deployment
72- echo "Using s3cmd to upload to S3-compatible storage"
68+ echo "Using rclone to upload to S3-compatible storage"
7369 echo "Bucket: ${S3_BUCKET_NAME_MASKED}"
7470
75- # Test bucket access
76- echo "Testing bucket access..."
77- if s3cmd ls s3://${{ secrets.S3_BUCKET_NAME }}/; then
71+ # Create a mime types file to ensure proper content types
72+ cat > mime.types << EOF
73+ # MIME types for web content
74+ text/html html htm
75+ text/css css
76+ text/javascript js
77+ application/javascript js
78+ application/json json
79+ text/plain txt md
80+ image/jpeg jpg jpeg
81+ image/png png
82+ image/svg+xml svg
83+ image/webp webp
84+ image/gif gif
85+ application/pdf pdf
86+ application/font-woff woff
87+ application/font-woff2 woff2
88+ EOF
89+
90+ # Test connection
91+ echo "Testing connection to S3-compatible storage..."
92+ if rclone ls s3:${{ secrets.S3_BUCKET_NAME }} --quiet; then
7893 echo "✅ Bucket exists and is accessible"
7994 else
8095 echo "❌ Bucket does not exist or is not accessible"
8196 exit 1
8297 fi
8398
84- # First, remove all existing files in the bucket
85- echo "Clearing existing files from bucket..."
86- s3cmd del --recursive --force s3://${{ secrets.S3_BUCKET_NAME }}/
87-
88- # Upload all files first - this will use auto mime-type detection
89- echo "Uploading files to S3-compatible storage..."
90- s3cmd sync --verbose --progress \
91- --exclude=".git/*" \
92- --no-check-md5 \
93- --delete-removed \
94- --guess-mime-type \
95- --add-header="Content-Disposition: inline" \
96- ./ s3://${{ secrets.S3_BUCKET_NAME }}/
97-
98- # Set content types for specific file types to ensure proper handling
99- echo "Setting content types for HTML files..."
100- find . -name "*.html" | while read file; do
101- rel_path=${file#./}
102- echo "Setting content-type for: $rel_path"
103- s3cmd modify --mime-type="text/html" \
104- --add-header="Content-Disposition: inline" \
105- s3://${{ secrets.S3_BUCKET_NAME }}/$rel_path
106- done
107-
108- echo "Setting content types for CSS files..."
109- find . -name "*.css" | while read file; do
110- rel_path=${file#./}
111- s3cmd modify --mime-type="text/css" \
112- --add-header="Content-Disposition: inline" \
113- s3://${{ secrets.S3_BUCKET_NAME }}/$rel_path
114- done
115-
116- echo "Setting content types for JavaScript files..."
117- find . -name "*.js" | while read file; do
118- rel_path=${file#./}
119- s3cmd modify --mime-type="application/javascript" \
120- --add-header="Content-Disposition: inline" \
121- s3://${{ secrets.S3_BUCKET_NAME }}/$rel_path
122- done
99+ # Sync files to S3, using proper metadata and content types
100+ echo "Syncing files to S3-compatible storage..."
101+ rclone sync --verbose --progress \
102+ --checksum \
103+ --update \
104+ --delete-after \
105+ --exclude ".git/**" \
106+ --exclude "mime.types" \
107+ --metadata-set "Content-Disposition=inline" \
108+ --mime-file mime.types \
109+ --s3-no-head \
110+ --s3-no-check-bucket \
111+ ./ s3:${{ secrets.S3_BUCKET_NAME }}
123112
124113 echo "Successfully deployed to S3-compatible storage"
125114 env :
0 commit comments