新增 web 页面 #33
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Image | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- 'v*' | |
paths: | |
- 'action.txt' | |
# 添加权限配置 | |
permissions: | |
contents: write | |
packages: write | |
issues: write | |
pull-requests: write | |
env: | |
DOCKER_IMAGE: ${{ github.repository }} # 请替换成你的 Docker Hub 用户名和镜像名 | |
PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x | |
jobs: | |
alist-sync-docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_IMAGE }} | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Get version from tag | |
if: startsWith(github.ref, 'refs/tags/') | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ env.PLATFORMS }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
provenance: false | |
- name: Update Docker Hub Description | |
if: github.event_name != 'pull_request' | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: ${{ env.DOCKER_IMAGE }} | |
readme-filepath: ./README.md | |
short-description: "Alist-Sync - A tool for syncing files between Alist storages" | |
# 以下是新增的 Release 相关步骤 | |
- name: Create Source Archive | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
# 创建临时目录 | |
TEMP_DIR="/tmp/alist-sync-release" | |
mkdir -p "$TEMP_DIR" | |
# 定义要包含的文件列表 | |
INCLUDE_FILES=( | |
"alist-sync-web.py" | |
"alist_sync.py" | |
"requirements.txt" | |
"Dockerfile" | |
"docker-compose.yml" | |
"README.md" | |
"static" | |
"templates" | |
) | |
# 定义平台列表 | |
PLATFORMS=( | |
"linux-386" | |
"linux-amd64" | |
"linux-arm-v6" | |
"linux-arm-v7" | |
"linux-arm64" | |
"linux-ppc64le" | |
"linux-s390x" | |
) | |
# 为每个平台创建一个包 | |
for platform in "${PLATFORMS[@]}"; do | |
# 创建平台特定的临时目录 | |
PLATFORM_DIR="$TEMP_DIR/$platform" | |
mkdir -p "$PLATFORM_DIR" | |
# 复制文件到平台目录 | |
for item in "${INCLUDE_FILES[@]}"; do | |
if [ -e "$item" ]; then | |
cp -r "$item" "$PLATFORM_DIR/" | |
fi | |
done | |
# 在平台目录中创建压缩包 | |
cd "$PLATFORM_DIR" | |
# 创建 ZIP 文件 | |
zip -r "alist-sync-${{ github.ref_name }}-${platform}.zip" ./* | |
# 创建 TAR.GZ 文件 | |
tar --exclude='.[^/]*' -czf "alist-sync-${{ github.ref_name }}-${platform}.tar.gz" ./* | |
# 移动压缩包到工作目录 | |
mv "alist-sync-${{ github.ref_name }}-${platform}.zip" "$GITHUB_WORKSPACE/" | |
mv "alist-sync-${{ github.ref_name }}-${platform}.tar.gz" "$GITHUB_WORKSPACE/" | |
done | |
- name: Generate Release Body | |
if: startsWith(github.ref, 'refs/tags/') | |
id: release_body | |
run: | | |
# 将 release 内容保存到输出变量 | |
CONTENT=$(cat RELEASE.md) | |
echo "RELEASE_BODY<<EOF" >> "$GITHUB_OUTPUT" | |
echo "$CONTENT" >> "$GITHUB_OUTPUT" | |
echo "EOF" >> "$GITHUB_OUTPUT" | |
- name: Create Release | |
if: startsWith(github.ref, 'refs/tags/') | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ github.ref_name }} | |
name: Release ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
body: ${{ steps.release_body.outputs.RELEASE_BODY }} | |
files: | | |
alist-sync-${{ github.ref_name }}-linux-386.zip | |
alist-sync-${{ github.ref_name }}-linux-386.tar.gz | |
alist-sync-${{ github.ref_name }}-linux-amd64.zip | |
alist-sync-${{ github.ref_name }}-linux-amd64.tar.gz | |
alist-sync-${{ github.ref_name }}-linux-arm-v6.zip | |
alist-sync-${{ github.ref_name }}-linux-arm-v6.tar.gz | |
alist-sync-${{ github.ref_name }}-linux-arm-v7.zip | |
alist-sync-${{ github.ref_name }}-linux-arm-v7.tar.gz | |
alist-sync-${{ github.ref_name }}-linux-arm64.zip | |
alist-sync-${{ github.ref_name }}-linux-arm64.tar.gz | |
alist-sync-${{ github.ref_name }}-linux-ppc64le.zip | |
alist-sync-${{ github.ref_name }}-linux-ppc64le.tar.gz | |
alist-sync-${{ github.ref_name }}-linux-s390x.zip | |
alist-sync-${{ github.ref_name }}-linux-s390x.tar.gz |