1
0

feat: Deprecate qiniu. Use S3 capable api

This commit is contained in:
2025-07-09 14:15:54 +08:00
parent 26642e8b22
commit b7cfbb298a
3 changed files with 21 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
# setup-zola # setup-zola
This action sets up Zola static site generator in your GitHub Actions workflow. 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 ## Usage
@@ -13,7 +13,7 @@ Basic usage:
version: "0.19.2" # Optional, defaults to 0.19.2 version: "0.19.2" # Optional, defaults to 0.19.2
access_key: ${{ secrets.S3_ACCESS_KEY }} # Required access_key: ${{ secrets.S3_ACCESS_KEY }} # Required
secret_key: ${{ secrets.S3_SECRET_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 bucket: ${{ secrets.S3_BUCKET }} # Required
``` ```

View File

@@ -1,3 +1,3 @@
python-dotenv python-dotenv
requests requests
qiniu boto3

View File

@@ -2,8 +2,8 @@ import os
import sys import sys
from dotenv import load_dotenv from dotenv import load_dotenv
import shutil import shutil
import requests import boto3
from qiniu import Auth from botocore.exceptions import ClientError
def install_zola(): def install_zola():
@@ -11,26 +11,30 @@ def install_zola():
access_key = os.environ["INPUT_ACCESS_KEY"] access_key = os.environ["INPUT_ACCESS_KEY"]
secret_key = os.environ["INPUT_SECRET_KEY"] secret_key = os.environ["INPUT_SECRET_KEY"]
endpoint = os.environ["INPUT_ENDPOINT"] endpoint = os.environ["INPUT_ENDPOINT"]
bucket = "omybucket" bucket = os.environ["INPUT_BUCKET"]
zola_filename = "zola-" + version zola_filename = "zola-" + version
try: try:
q = Auth(access_key, secret_key) # Create S3 client for S3-compatible storage
base_url = "%s/%s" % (endpoint, zola_filename) s3_client = boto3.client(
private_url = q.private_download_url(base_url, expires=3600) 's3',
response = requests.get(private_url) aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
endpoint_url=endpoint
)
if response.status_code == 200: # Download file from S3-compatible storage
# 将文件内容保存到本地 s3_client.download_file(bucket, zola_filename, zola_filename)
with open(zola_filename, "wb") as f: print("文件下载成功!")
f.write(response.content)
print("文件下载成功!")
else:
raise Exception(f"下载失败: {response.status_code}")
# Install zola binary
shutil.copy(zola_filename, "/usr/local/bin/zola") shutil.copy(zola_filename, "/usr/local/bin/zola")
os.chmod("/usr/local/bin/zola", 0o755) 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: except Exception as e:
print(f"Error: {str(e)}") print(f"Error: {str(e)}")
sys.exit(1) sys.exit(1)