Compare commits
11
Commits
43dc8f9856
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6a9a8ea50 | ||
|
|
46428ce02f | ||
|
|
e0c709ad5c | ||
|
|
66ce4bce0a | ||
|
|
d5e68ab6fc | ||
|
|
6f1a25f7fa | ||
|
|
1add059bcc | ||
|
|
06e73d49d0 | ||
|
|
9fdbb55218 | ||
|
|
2301f7075e | ||
|
|
b491c8ac86 |
@@ -0,0 +1,58 @@
|
|||||||
|
name: Build and Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
verify:
|
||||||
|
runs-on: laralog-ci
|
||||||
|
steps:
|
||||||
|
- uses: https://gitea.neatcn.com/gouki/action-checkout@v4
|
||||||
|
- name: Verify CI runtime
|
||||||
|
run: |
|
||||||
|
php -r 'exit(PHP_VERSION_ID >= 80200 ? 0 : 1);'
|
||||||
|
node --version
|
||||||
|
composer --version
|
||||||
|
- name: Prepare env (sqlite for package discovery)
|
||||||
|
run: |
|
||||||
|
cp .env.example .env
|
||||||
|
mkdir -p database
|
||||||
|
touch database/database.sqlite
|
||||||
|
- name: Install backend dependencies
|
||||||
|
run: |
|
||||||
|
composer install --no-interaction --prefer-dist --ignore-platform-req=ext-exif
|
||||||
|
npm install
|
||||||
|
- name: Build backend assets
|
||||||
|
run: npm run build
|
||||||
|
- name: Persist built assets for deploy job
|
||||||
|
run: |
|
||||||
|
dest="/ci-artifacts/build-${{ gitea.sha }}"
|
||||||
|
test -d /ci-artifacts
|
||||||
|
rm -rf "$dest"
|
||||||
|
mkdir -p "$dest"
|
||||||
|
cp -a public/build/. "$dest/"
|
||||||
|
test -f "$dest/manifest.json"
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: verify
|
||||||
|
runs-on: production
|
||||||
|
steps:
|
||||||
|
- uses: https://gitea.neatcn.com/gouki/action-checkout@v4
|
||||||
|
- name: Restore built assets from runner host
|
||||||
|
run: |
|
||||||
|
src="/opt/laralog/ci-artifacts/build-${{ gitea.sha }}"
|
||||||
|
test -d "$src"
|
||||||
|
mkdir -p public/build
|
||||||
|
cp -a "$src/." public/build/
|
||||||
|
test -f public/build/manifest.json
|
||||||
|
- uses: https://gitea.neatcn.com/gouki/deployment-toolkit/actions/laravel-release@v1.0.6
|
||||||
|
with:
|
||||||
|
source-dir: .
|
||||||
|
deploy-root: /opt/1panel/apps/openresty/openresty/www/sites/laralog.neatstudio.com/index
|
||||||
|
container-deploy-root: /www/sites/laralog.neatstudio.com/index
|
||||||
|
php-container: php83-ex
|
||||||
|
healthcheck-url: https://laralog.neatstudio.com/up
|
||||||
|
backup-command: "mysqldump -h10.0.4.7 -ularalog -p'Laralog#2026' laralog | gzip > /opt/laralog/backups/laralog-${{ gitea.sha }}.sql.gz"
|
||||||
|
release-id: ${{ gitea.sha }}
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main, master, develop]
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
services:
|
|
||||||
mysql:
|
|
||||||
image: mysql:8.0
|
|
||||||
env:
|
|
||||||
MYSQL_ROOT_PASSWORD: root
|
|
||||||
MYSQL_DATABASE: laralog_test
|
|
||||||
ports:
|
|
||||||
- 3306:3306
|
|
||||||
options: >-
|
|
||||||
--health-cmd="mysqladmin ping -proot"
|
|
||||||
--health-interval=10s
|
|
||||||
--health-timeout=5s
|
|
||||||
--health-retries=5
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup PHP
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: '8.2'
|
|
||||||
extensions: mbstring, dom, pdo_mysql, sqlite3, gd, redis
|
|
||||||
coverage: none
|
|
||||||
|
|
||||||
- name: Cache Composer
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: vendor
|
|
||||||
key: composer-${{ hashFiles('composer.lock') }}
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: composer install --no-interaction --prefer-dist --no-progress
|
|
||||||
|
|
||||||
- name: Env
|
|
||||||
run: |
|
|
||||||
cp .env.example .env
|
|
||||||
php artisan key:generate
|
|
||||||
touch database/database.sqlite
|
|
||||||
|
|
||||||
- name: Lint
|
|
||||||
run: |
|
|
||||||
find app plugins config database -name '*.php' -print0 | xargs -0 -n1 php -l
|
|
||||||
|
|
||||||
- name: Migrate & Seed (sqlite)
|
|
||||||
run: php artisan migrate --seed --force
|
|
||||||
|
|
||||||
- name: Run tests (sqlite)
|
|
||||||
run: php artisan test
|
|
||||||
|
|
||||||
# 生产走 MySQL:可选并行 MySQL 测试
|
|
||||||
- name: Run tests (mysql)
|
|
||||||
env:
|
|
||||||
DB_CONNECTION: mysql
|
|
||||||
DB_HOST: 127.0.0.1
|
|
||||||
DB_PORT: 3306
|
|
||||||
DB_DATABASE: laralog_test
|
|
||||||
DB_USERNAME: root
|
|
||||||
DB_PASSWORD: root
|
|
||||||
run: php artisan test
|
|
||||||
|
|
||||||
# 生产部署示例(SSH + rsync)。真实环境按需开启并配置 secrets:
|
|
||||||
# DEPLOY_HOST / DEPLOY_USER / DEPLOY_PATH / DEPLOY_SSH_KEY
|
|
||||||
deploy:
|
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
needs: test
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
environment: production
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Deploy via SSH
|
|
||||||
uses: appleboy/ssh-action@v1
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.DEPLOY_HOST }}
|
|
||||||
username: ${{ secrets.DEPLOY_USER }}
|
|
||||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
||||||
script: |
|
|
||||||
cd ${{ secrets.DEPLOY_PATH }}
|
|
||||||
git pull origin main
|
|
||||||
composer install --no-dev --no-interaction --prefer-dist
|
|
||||||
php artisan migrate --force
|
|
||||||
php artisan config:cache
|
|
||||||
php artisan route:cache
|
|
||||||
php artisan view:cache
|
|
||||||
php artisan theme:publish
|
|
||||||
pm2 restart laralog-workerman laralog-schedule || pm2 start ecosystem.config.js
|
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
schema_version: 1
|
||||||
|
generated_at: "2026-08-13T10:34:55Z"
|
||||||
|
php:
|
||||||
|
version: 8.2.30
|
||||||
|
path: /Users/admin/Library/Application Support/Herd/bin//php
|
||||||
|
extensions:
|
||||||
|
- name: redis
|
||||||
|
constraint: '*'
|
||||||
|
installed: 6.3.0
|
||||||
|
loaded: true
|
||||||
|
- name: swoole
|
||||||
|
constraint: ^6.0
|
||||||
|
installed: 6.2.1
|
||||||
|
loaded: true
|
||||||
|
- name: xdebug
|
||||||
|
constraint: '*'
|
||||||
|
installed: ""
|
||||||
|
loaded: false
|
||||||
|
services: []
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
# xpier 项目钉定配置(可选:没有它 xpier 也能自动检测)
|
||||||
|
# 所有字段都可选,不需要的直接删掉或保持注释。字段说明见 docs/architecture.md。
|
||||||
|
|
||||||
|
runtime: fpm # 项目类型/运行时(决定 xpier up 怎么处理):
|
||||||
|
# ┌ fpm 标准 PHP / Laravel —— 无需 up:cd 项目 && xpier link,nginx+php-fpm 直接服务,访问 <目录名>.test
|
||||||
|
# ├ static 静态站点 —— 同 fpm,link 后 nginx 直接出文件
|
||||||
|
# ├ hyperf Hyperf 常驻服务 —— 在下方 apps: 写启动命令,xpier up 拉起
|
||||||
|
# ├ swoole Swoole 常驻服务 —— 同 hyperf
|
||||||
|
# └ frankenphp FrankenPHP —— 同 hyperf
|
||||||
|
# php: "8.4" # 钉定 PHP 版本(如 "8.2" / "8.4")
|
||||||
|
|
||||||
|
extensions: # 需要的 PHP 扩展(键=扩展名, 值=版本约束)
|
||||||
|
swoole: "^6.0" # 约束:"*" 任意 / "^6.0" / ">=6.0"
|
||||||
|
redis: "*"
|
||||||
|
xdebug: "*"
|
||||||
|
# 装法:xpier sync --apply 或 xpier ext:install swoole --php 8.4
|
||||||
|
|
||||||
|
# services: # 依赖的系统服务(sync --apply 会 brew 安装)
|
||||||
|
# - mysql
|
||||||
|
# - redis
|
||||||
|
|
||||||
|
apps: # 多应用编排(与 dev.yaml 同构,dev.yaml 优先;两种条目可混用)
|
||||||
|
# # 网站型:无 cmd —— up 自动注册站点(相当于 link),nginx+php-fpm 直接服务
|
||||||
|
blog:
|
||||||
|
dir: . # 可选,默认当前目录
|
||||||
|
domain: larablog.test # 必填:访问域名
|
||||||
|
secure: true # 可选:开启 https(默认 http)
|
||||||
|
php: "8.4" # 可选:固定 PHP 版本
|
||||||
|
|
||||||
|
# # 进程型:有 cmd —— up 托管常驻进程(Hyperf/vite...)
|
||||||
|
# php-server:
|
||||||
|
# dir: /path
|
||||||
|
# cmd: php bin/hyperf.php server:watch
|
||||||
|
# ports: ["9501"]
|
||||||
|
# domain: api.test # 可选:生成 nginx 反代
|
||||||
|
# node: "20" # 可选:经 nvm 固定 Node
|
||||||
|
# extensions: [swoole] # 可选:启动前检查扩展
|
||||||
@@ -137,7 +137,9 @@ class PostContentRenderer
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$replacement = $type === 'img'
|
// 老 sablog 的 [attach=xx] 对图片附件就是直接贴图,mime 是图片时用 <img>
|
||||||
|
$isImage = str_starts_with((string) $media->mime_type, 'image/');
|
||||||
|
$replacement = $type === 'img' || $isImage
|
||||||
? sprintf('<img src="%s" alt="%s" loading="lazy" />', $media->getUrl(), e($media->name))
|
? sprintf('<img src="%s" alt="%s" loading="lazy" />', $media->getUrl(), e($media->name))
|
||||||
: sprintf('<a href="%s">%s</a>', $media->getUrl(), e($media->file_name));
|
: sprintf('<a href="%s">%s</a>', $media->getUrl(), e($media->file_name));
|
||||||
|
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ class SablogImport extends Command
|
|||||||
'regip' => $row['regip'] ?: null,
|
'regip' => $row['regip'] ?: null,
|
||||||
'logintime' => $row['logintime'] ? date('Y-m-d H:i:s', (int) $row['logintime']) : null,
|
'logintime' => $row['logintime'] ? date('Y-m-d H:i:s', (int) $row['logintime']) : null,
|
||||||
'lastpost_at' => $row['lastpost'] ? date('Y-m-d H:i:s', (int) $row['lastpost']) : null,
|
'lastpost_at' => $row['lastpost'] ? date('Y-m-d H:i:s', (int) $row['lastpost']) : null,
|
||||||
'created_at' => date('Y-m-d H:i:s', (int) $row['regdateline']),
|
'created_at' => ($ts = (int) $row['regdateline']) > 0 ? date('Y-m-d H:i:s', $ts) : now(),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -252,10 +252,16 @@ class SablogImport extends Command
|
|||||||
foreach ($this->rows('articles') as $row) {
|
foreach ($this->rows('articles') as $row) {
|
||||||
$slug = SlugGenerator::make($row['title'], 'posts', 'slug', ignoreId: (int) $row['articleid'], fallback: 'post-'.$row['articleid']);
|
$slug = SlugGenerator::make($row['title'], 'posts', 'slug', ignoreId: (int) $row['articleid'], fallback: 'post-'.$row['articleid']);
|
||||||
$status = (int) $row['visible'] === 1 ? 'published' : 'draft';
|
$status = (int) $row['visible'] === 1 ? 'published' : 'draft';
|
||||||
$dateline = date('Y-m-d H:i:s', (int) $row['dateline']);
|
$dateline = ($ts = (int) $row['dateline']) > 0 ? date('Y-m-d H:i:s', $ts) : now()->toDateTimeString();
|
||||||
|
|
||||||
|
// 老库存在已删除分类的孤儿文章;目标列可空,置 null
|
||||||
|
$categoryId = (int) $row['cid'] ?: null;
|
||||||
|
if ($categoryId !== null && ! DB::table('categories')->where('id', $categoryId)->exists()) {
|
||||||
|
$categoryId = null;
|
||||||
|
}
|
||||||
|
|
||||||
DB::table('posts')->updateOrInsert(['id' => (int) $row['articleid']], [
|
DB::table('posts')->updateOrInsert(['id' => (int) $row['articleid']], [
|
||||||
'category_id' => (int) $row['cid'] ?: null,
|
'category_id' => $categoryId,
|
||||||
'user_id' => (int) $row['uid'] ?: null,
|
'user_id' => (int) $row['uid'] ?: null,
|
||||||
'title' => $row['title'],
|
'title' => $row['title'],
|
||||||
'slug' => $slug,
|
'slug' => $slug,
|
||||||
@@ -325,7 +331,7 @@ class SablogImport extends Command
|
|||||||
'content' => $row['content'],
|
'content' => $row['content'],
|
||||||
'ip' => $row['ipaddress'] ?: null,
|
'ip' => $row['ipaddress'] ?: null,
|
||||||
'status' => (int) $row['visible'] === 1 ? 'published' : 'pending',
|
'status' => (int) $row['visible'] === 1 ? 'published' : 'pending',
|
||||||
'created_at' => date('Y-m-d H:i:s', (int) $row['dateline']),
|
'created_at' => ($ts = (int) $row['dateline']) > 0 ? date('Y-m-d H:i:s', $ts) : null,
|
||||||
]);
|
]);
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
@@ -24,7 +25,8 @@ return new class extends Migration
|
|||||||
$table->timestamp('last_clicked_at')->nullable();
|
$table->timestamp('last_clicked_at')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
$table->index('target_url');
|
// MySQL 5.7 不支持对 TEXT 建全值索引,用前缀索引
|
||||||
|
$table->index([DB::raw('target_url(191)')], 'redirects_target_url_index');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,16 +109,29 @@ Route::get('/themes/{theme}/assets/{path}', [ThemeAssetController::class, 'show'
|
|||||||
Route::get('/show-{id}-{page}.html', [LegacyController::class, 'showRewritten'])
|
Route::get('/show-{id}-{page}.html', [LegacyController::class, 'showRewritten'])
|
||||||
->where(['id' => '\d+', 'page' => '\d+']);
|
->where(['id' => '\d+', 'page' => '\d+']);
|
||||||
Route::get('/show-{id}.html', [LegacyController::class, 'showRewritten'])->where('id', '\d+');
|
Route::get('/show-{id}.html', [LegacyController::class, 'showRewritten'])->where('id', '\d+');
|
||||||
|
Route::get('/show-{id}-{page}.shtml', [LegacyController::class, 'showRewritten'])
|
||||||
|
->where(['id' => '\d+', 'page' => '\d+']);
|
||||||
|
Route::get('/show-{id}.shtml', [LegacyController::class, 'showRewritten'])->where('id', '\d+');
|
||||||
Route::get('/category-{cid}-{page}.html', [LegacyController::class, 'categoryRewritten'])
|
Route::get('/category-{cid}-{page}.html', [LegacyController::class, 'categoryRewritten'])
|
||||||
->where(['cid' => '\d+', 'page' => '\d+']);
|
->where(['cid' => '\d+', 'page' => '\d+']);
|
||||||
Route::get('/category-{cid}.html', [LegacyController::class, 'categoryRewritten'])->where('cid', '\d+');
|
Route::get('/category-{cid}.html', [LegacyController::class, 'categoryRewritten'])->where('cid', '\d+');
|
||||||
|
Route::get('/category-{cid}-{page}.shtml', [LegacyController::class, 'categoryRewritten'])
|
||||||
|
->where(['cid' => '\d+', 'page' => '\d+']);
|
||||||
|
Route::get('/category-{cid}.shtml', [LegacyController::class, 'categoryRewritten'])->where('cid', '\d+');
|
||||||
Route::get('/archives-{date}-{page}.html', [LegacyController::class, 'archivesRewritten'])
|
Route::get('/archives-{date}-{page}.html', [LegacyController::class, 'archivesRewritten'])
|
||||||
->where(['date' => '\d+', 'page' => '\d+']);
|
->where(['date' => '\d+', 'page' => '\d+']);
|
||||||
Route::get('/archives-{date}.html', [LegacyController::class, 'archivesRewritten'])->where('date', '\d+');
|
Route::get('/archives-{date}.html', [LegacyController::class, 'archivesRewritten'])->where('date', '\d+');
|
||||||
|
Route::get('/archives-{date}-{page}.shtml', [LegacyController::class, 'archivesRewritten'])
|
||||||
|
->where(['date' => '\d+', 'page' => '\d+']);
|
||||||
|
Route::get('/archives-{date}.shtml', [LegacyController::class, 'archivesRewritten'])->where('date', '\d+');
|
||||||
Route::get('/tagslist-{page}.html', fn () => redirect()->route('tags', [], 301))->where('page', '\d+');
|
Route::get('/tagslist-{page}.html', fn () => redirect()->route('tags', [], 301))->where('page', '\d+');
|
||||||
Route::get('/tagslist.html', fn () => redirect()->route('tags', [], 301));
|
Route::get('/tagslist.html', fn () => redirect()->route('tags', [], 301));
|
||||||
|
Route::get('/tagslist-{page}.shtml', fn () => redirect()->route('tags', [], 301))->where('page', '\d+');
|
||||||
|
Route::get('/tagslist.shtml', fn () => redirect()->route('tags', [], 301));
|
||||||
Route::get('/comments-{page}.html', fn () => redirect()->route('comments', [], 301))->where('page', '\d+');
|
Route::get('/comments-{page}.html', fn () => redirect()->route('comments', [], 301))->where('page', '\d+');
|
||||||
|
Route::get('/comments-{page}.shtml', fn () => redirect()->route('comments', [], 301))->where('page', '\d+');
|
||||||
Route::get('/search-{page}.html', fn () => redirect()->route('search', [], 301))->where('page', '\d+');
|
Route::get('/search-{page}.html', fn () => redirect()->route('search', [], 301))->where('page', '\d+');
|
||||||
|
Route::get('/search-{page}.shtml', fn () => redirect()->route('search', [], 301))->where('page', '\d+');
|
||||||
Route::get('/reg.shtml', fn () => redirect()->route('register', [], 301));
|
Route::get('/reg.shtml', fn () => redirect()->route('register', [], 301));
|
||||||
Route::get('/tag/{name}', [LegacyController::class, 'tagByName']);
|
Route::get('/tag/{name}', [LegacyController::class, 'tagByName']);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user