update& switch to python version
This commit is contained in:
parent
ad28b73245
commit
68db5879c6
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.env
|
40
README.md
40
README.md
@ -1,11 +1,45 @@
|
||||
# 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.
|
||||
|
||||
## Usage
|
||||
|
||||
Basic usage:
|
||||
|
||||
```yaml
|
||||
uses: my-org/setup-zola@v1
|
||||
with:
|
||||
version: "0.19.2" # Optional
|
||||
- uses: my-org/setup-zola@v1
|
||||
with:
|
||||
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
|
||||
bucket: ${{ secrets.S3_BUCKET }} # Required
|
||||
```
|
||||
|
||||
## Example workflow
|
||||
|
||||
```yaml
|
||||
name: Build with Zola
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Zola
|
||||
uses: my-org/setup-zola@v1
|
||||
with:
|
||||
version: "0.19.2"
|
||||
access_key: ${{ secrets.S3_ACCESS_KEY }}
|
||||
secret_key: ${{ secrets.S3_SECRET_KEY }}
|
||||
endpoint: "https://your-s3-endpoint.com"
|
||||
bucket: ${{ secrets.S3_BUCKET }}
|
||||
- name: Build site
|
||||
run: zola build
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
29
action.yml
29
action.yml
@ -4,12 +4,33 @@ inputs:
|
||||
version:
|
||||
description: "The version of Zola to install"
|
||||
required: false
|
||||
default: "0.18.0"
|
||||
default: "0.19.2"
|
||||
access_key:
|
||||
description: "s3 Access Key"
|
||||
required: true
|
||||
secret_key:
|
||||
description: "s3 Secret Key"
|
||||
required: true
|
||||
endpoint:
|
||||
description: "S3 endpoint URL"
|
||||
required: true
|
||||
bucket:
|
||||
description: "S3 bucket"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: pip install -r ./requirements.txt
|
||||
|
||||
- name: Run install script
|
||||
shell: bash
|
||||
run: |
|
||||
chmod +x ${{ github.action_path }}/scripts/install_zola.sh
|
||||
${{ github.action_path }}/scripts/install_zola.sh ${{ inputs.version }}
|
||||
env:
|
||||
INPUT_VERSION: ${{ inputs.version }}
|
||||
INPUT_ACCESS_KEY: ${{ inputs.access_key }}
|
||||
INPUT_SECRET_KEY: ${{ inputs.secret_key }}
|
||||
INPUT_ENDPOINT: ${{ inputs.endpoint }}
|
||||
INPUT_BUCKET: ${{ inputs.bucket }}
|
||||
run: python3 ${{ github.action_path }}/scripts/install_zola.py
|
||||
|
8
requirements.txt
Normal file
8
requirements.txt
Normal file
@ -0,0 +1,8 @@
|
||||
boto3==1.36.17
|
||||
botocore==1.36.17
|
||||
jmespath==1.0.1
|
||||
python-dateutil==2.9.0.post0
|
||||
python-dotenv==1.0.1
|
||||
s3transfer==0.11.2
|
||||
six==1.17.0
|
||||
urllib3==2.3.0
|
38
scripts/install_zola.py
Normal file
38
scripts/install_zola.py
Normal file
@ -0,0 +1,38 @@
|
||||
import os
|
||||
import sys
|
||||
import boto3
|
||||
from botocore.client import Config
|
||||
from dotenv import load_dotenv
|
||||
import shutil
|
||||
|
||||
|
||||
def install_zola():
|
||||
version = os.environ["INPUT_VERSION"]
|
||||
access_key = os.environ["INPUT_ACCESS_KEY"]
|
||||
secret_key = os.environ["INPUT_SECRET_KEY"]
|
||||
endpoint = os.environ["INPUT_ENDPOINT"]
|
||||
bucket = "omybucket"
|
||||
|
||||
# 配置 S3 客户端
|
||||
s3 = boto3.client(
|
||||
"s3",
|
||||
endpoint_url=endpoint,
|
||||
aws_access_key_id=access_key,
|
||||
aws_secret_access_key=secret_key,
|
||||
config=Config(signature_version="s3v4"),
|
||||
)
|
||||
|
||||
zola_filename = "zola-" + version
|
||||
|
||||
try:
|
||||
s3.download_file(bucket, zola_filename, zola_filename)
|
||||
shutil.copy(zola_filename, "/usr/local/bin/zola")
|
||||
os.chmod("/usr/local/bin/zola", 0o755)
|
||||
except Exception as e:
|
||||
print(f"Error: {str(e)}")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
load_dotenv()
|
||||
install_zola()
|
@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
ZOLA_VERSION="0.19.2"
|
||||
|
||||
BASE_URL="https://git.mamahaha.work/api/packages/actions/generic/zola"
|
||||
echo "Checking Zola version $ZOLA_VERSION..."
|
||||
|
||||
# 使用 -I 只获取头信息,-s 静默模式
|
||||
if ! curl -Is "${BASE_URL}/${ZOLA_VERSION}/zola" | grep -q "200 OK"; then
|
||||
echo "Error: Version $ZOLA_VERSION not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Downloading Zola version $ZOLA_VERSION..."
|
||||
curl -OJ "${BASE_URL}/${ZOLA_VERSION}/zola"
|
||||
|
||||
chmod +x zola
|
||||
sudo mv zola /usr/local/bin
|
||||
|
||||
echo "Zola installed successfully."
|
Loading…
x
Reference in New Issue
Block a user