feat: Deprecate qiniu. Use S3 capable api
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# setup-zola
|
||||
|
||||
This action sets up Zola static site generator in your GitHub Actions workflow.
|
||||
It supports downloading Zola from any S3-compatible storage service.
|
||||
It supports downloading Zola from S3-compatible storage services including AWS S3, Cloudflare R2, MinIO, and others.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -13,7 +13,7 @@ Basic usage:
|
||||
version: "0.19.2" # Optional, defaults to 0.19.2
|
||||
access_key: ${{ secrets.S3_ACCESS_KEY }} # Required
|
||||
secret_key: ${{ secrets.S3_SECRET_KEY }} # Required
|
||||
endpoint: "https://your-s3-endpoint.com" # Required
|
||||
endpoint: "https://your-s3-endpoint.com" # Required (e.g., for R2: https://accountid.r2.cloudflarestorage.com)
|
||||
bucket: ${{ secrets.S3_BUCKET }} # Required
|
||||
```
|
||||
|
||||
|
@@ -1,3 +1,3 @@
|
||||
python-dotenv
|
||||
requests
|
||||
qiniu
|
||||
boto3
|
||||
|
@@ -2,8 +2,8 @@ import os
|
||||
import sys
|
||||
from dotenv import load_dotenv
|
||||
import shutil
|
||||
import requests
|
||||
from qiniu import Auth
|
||||
import boto3
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
|
||||
def install_zola():
|
||||
@@ -11,26 +11,30 @@ def install_zola():
|
||||
access_key = os.environ["INPUT_ACCESS_KEY"]
|
||||
secret_key = os.environ["INPUT_SECRET_KEY"]
|
||||
endpoint = os.environ["INPUT_ENDPOINT"]
|
||||
bucket = "omybucket"
|
||||
bucket = os.environ["INPUT_BUCKET"]
|
||||
|
||||
zola_filename = "zola-" + version
|
||||
|
||||
try:
|
||||
q = Auth(access_key, secret_key)
|
||||
base_url = "%s/%s" % (endpoint, zola_filename)
|
||||
private_url = q.private_download_url(base_url, expires=3600)
|
||||
response = requests.get(private_url)
|
||||
# Create S3 client for S3-compatible storage
|
||||
s3_client = boto3.client(
|
||||
's3',
|
||||
aws_access_key_id=access_key,
|
||||
aws_secret_access_key=secret_key,
|
||||
endpoint_url=endpoint
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
# 将文件内容保存到本地
|
||||
with open(zola_filename, "wb") as f:
|
||||
f.write(response.content)
|
||||
# Download file from S3-compatible storage
|
||||
s3_client.download_file(bucket, zola_filename, zola_filename)
|
||||
print("文件下载成功!")
|
||||
else:
|
||||
raise Exception(f"下载失败: {response.status_code}")
|
||||
|
||||
# Install zola binary
|
||||
shutil.copy(zola_filename, "/usr/local/bin/zola")
|
||||
os.chmod("/usr/local/bin/zola", 0o755)
|
||||
print("Zola 安装成功!")
|
||||
except ClientError as e:
|
||||
print(f"S3 Error: {str(e)}")
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"Error: {str(e)}")
|
||||
sys.exit(1)
|
||||
|
Reference in New Issue
Block a user