init: 初始化

This commit is contained in:
Montia37
2025-08-13 04:32:05 +08:00
commit af6f7b1d09
343 changed files with 9919 additions and 0 deletions

126
.github/workflows/build.yaml vendored Normal file
View File

@@ -0,0 +1,126 @@
name: Build and Release Assets
on:
workflow_dispatch:
push:
tags:
- "v*"
release:
types: [created]
jobs:
build-and-package:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn
- name: Build project
run: yarn build
- name: Update theme configuration
run: |
# Get current date in YY.MM.DD format
VERSION_DATE=$(date +"%y.%m.%d")
# Get commit hash (short)
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "VERSION_DATE=${VERSION_DATE}" >> $GITHUB_ENV
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
# Update komari-theme.json with new version and description
jq --arg version "$VERSION_DATE" \
--arg desc "Theme for Komari Monitor (commit: $COMMIT_HASH)" \
'.version = $version | .description = $desc' \
komari-theme.json > komari-theme-updated.json
mv komari-theme-updated.json komari-theme.json
echo "Updated theme configuration:"
cat komari-theme.json
- name: Verify required files exist
run: |
echo "Checking required files..."
ls -la preview.png || (echo "preview.png not found" && exit 1)
ls -la komari-theme.json || (echo "komari-theme.json not found" && exit 1)
ls -la dist/ || (echo "dist/ directory not found" && exit 1)
echo "All required files found!"
- name: Create theme package
run: |
# Create a temporary directory for the package
mkdir -p theme-package
# Copy required files
cp preview.png theme-package/
cp komari-theme.json theme-package/
cp -r dist/ theme-package/
# Create zip file with version and commit hash
ZIP_NAME="komari-theme-purcarte-v${VERSION_DATE}-${COMMIT_HASH}.zip"
cd theme-package
zip -r ../${ZIP_NAME} .
cd ..
echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV
echo "Created package: ${ZIP_NAME}"
ls -la ${ZIP_NAME}
create-release:
needs: build-and-package
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: theme-package
path: .
- name: Display structure of downloaded files
run: ls -R
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
body: |
New release based on commit ${{ env.COMMIT_HASH }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.ZIP_NAME }}
asset_name: ${{ env.ZIP_NAME }}
asset_content_type: application/zip

60
.github/workflows/development.yaml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: Development Environment
on:
# Temporarily disabled
# push:
# branches: [main]
# pull_request:
# branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Setup SSH Key
uses: webfactory/ssh-agent@v0.8.0
with:
ssh-private-key: ${{ secrets.PRODUCTION_SSH_KEY }}
- name: Add host to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ vars.PRODUCTION_SERVER }} >> ~/.ssh/known_hosts
- name: Deploy to production server
run: |
rsync -avz --delete dist/ root@${{ vars.PRODUCTION_SERVER }}:${{ vars.PRODUCTION_DIR }}

89
.github/workflows/preview-theme.yaml vendored Normal file
View File

@@ -0,0 +1,89 @@
name: Build Theme Package
on:
push:
branches:
- dev
jobs:
build-and-package:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn
- name: Build project
run: yarn build
- name: Update theme configuration
run: |
# Get current date in YY.MM.DD format
VERSION_DATE=$(date +"%y.%m.%d")
# Get commit hash (short)
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "VERSION_DATE=${VERSION_DATE}" >> $GITHUB_ENV
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
# Update komari-theme.json with new version and description
jq --arg version "$VERSION_DATE" \
--arg desc "Preview theme for Komari Monitor (commit: $COMMIT_HASH)" \
'.version = $version | .description = $desc' \
komari-theme.json > komari-theme-updated.json
mv komari-theme-updated.json komari-theme.json
echo "Updated theme configuration:"
cat komari-theme.json
- name: Verify required files exist
run: |
echo "Checking required files..."
ls -la preview.png || (echo "preview.png not found" && exit 1)
ls -la komari-theme.json || (echo "komari-theme.json not found" && exit 1)
ls -la dist/ || (echo "dist/ directory not found" && exit 1)
echo "All required files found!"
- name: Create theme package
run: |
# Create a temporary directory for the package
mkdir -p theme-package
# Copy required files
cp preview.png theme-package/
cp komari-theme.json theme-package/
cp -r dist/ theme-package/
# Create zip file with version and commit hash
ZIP_NAME="komari-theme-purcarte-v${VERSION_DATE}-${COMMIT_HASH}.zip"
cd theme-package
zip -r ../${ZIP_NAME} .
cd ..
echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV
echo "Created package: ${ZIP_NAME}"
ls -la ${ZIP_NAME}
- name: Upload theme as artifacts
uses: actions/upload-artifact@v4
with:
name: komari-theme-purcarte-v${{ env.VERSION_DATE }}-${{ env.COMMIT_HASH }}
path: |
preview.png
komari-theme.json
dist/
retention-days: 90