Commit 5fca2b43 authored by nanahira's avatar nanahira

first

parents
Pipeline #33675 failed with stages
in 29 seconds
/dist
/workspace
stages:
- prepare
- pack
- deploy
variables:
GIT_DEPTH: "1"
check:
stage: prepare
dependencies: []
image: git-registry.mycard.moe/nanahira/srvpro:lite
tags:
- linux
script:
- apt update --allow-insecure-repositories && apt -y install sqlite3 git
- ./run.sh
variables:
YGOPRO_SERVER_PATH: /ygopro-server/ygopro
SIZE_LIMIT_MB: 100
KEEP_PERIOD_DAYS: 30
artifacts:
paths:
- dist
pack:
stage: pack
dependencies:
- check
tags:
- linux
script:
- mkdir -p upload server
- mv dist deploy/content
- cd deploy/content
- 7z a -mx9 ../ygopro-custom-free.zip *
- 7z a -mx9 ../ygopro2-custom-free-ypk.zip strings.conf custom-free.cdb pics script
- cp -rf custom-free.cdb ../../server/
- cp -rf script ../../server/
- cd ..
- mv ygopro2-custom-free-ypk.zip ygopro2-custom-free.ypk
- cd ..
artifacts:
paths:
- upload
- server
upload_minio:
stage: deploy
dependencies:
- pack
tags:
- linux
script:
- aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete upload/ s3://mycard/ygopro-custom-free
.deploy_to_server:
stage: deploy
tags:
- linux
dependencies:
- pack
script:
- apt update && apt -y install openssh-client rsync coreutils
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $SERVER_HOST >> ~/.ssh/known_hosts
- echo $NANAHIRA_SSH_KEY | base64 --decode > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/*
- rsync -4cavzP --exclude=pics --delete ./server/ $SERVER_USER@$SERVER_HOST:$SERVER_PATH
only:
- master
- tags
deploy_to_finale:
extends: .deploy_to_server
variables:
SERVER_HOST: diyfree.momobako.com
SERVER_USER: root
SERVER_PATH: ~/ygopro-custom-free/expansions
# ygopro-custom-free
允许大家自由上传 DIY 卡的服务器。
## 服务器地址
- 服务器地址:`diyfree.momobako.com`
- 端口:`1922`
## 整合包下载
- [YPK 文件](https://cdn02.moecube.com/ygopro-custom-free/ygopro-custom-free.ypk)
- [ZIP 文件](https://cdn02.moecube.com/ygopro-custom-free/ygopro-custom-free.zip)
- 单独文件下载: `https://cdn02.moecube.com/ygopro-custom-free/contents/`
## 上传卡片
1. 制作自己的 DIY 卡仓库,放置在 GitHub 或者 MCGit 下。仓库需要包含:
- `*.cdb`
- `pics`
- `script`
- `strings.conf`(可选)
2. 向本仓库提交 Pull Request,在 repos 目录里面创建文件,放入你的仓库地址。(也可以找 FiNALE 管理员完成这一步)
3. 等管理员审核通过之后,这个仓库的卡将会被永久接受。
### 「审核」
虽然这里没有传统意义的审核,但是系统会自动审核一些内容。如果你的卡片有问题,系统会自动拒绝收录你的仓库的卡片。
- 卡片不能有任何红字(任何 1 张有红字会导致整个仓库被拒绝收录)
- 如果卡片有红字,那么你会发现整合包里面 redtexts.txt 会有你的卡片的报错信息。
- 仓库必须活跃。如果仓库 30 天以上没有提交,系统也会拒绝收录。
- 仓库文件大小不得超过 100 MB。
https://github.com/jwyxym/diy-error
https://github.com/jwyxym/xiaoye-diy
#!/bin/bash
echo "Cleaning up workspace and dist directories"
rm -rf workspace dist || true
mkdir -p workspace dist/redtexts dist/pics dist/script
echo '# Auto generated by ygopro-custom-free' > dist/strings.conf
# YGOPRO_SERVER_PATH="/home/nanahira/ygo/srvpro/ygopro"
# SIZE_LIMIT_MB=100
# KEEP_PERIOD_DAYS=30
CURRENT_TIME=$(date +%s)
process_repo() {
repo_url="$1"
repo_name="$(basename $repo_url | sed 's/.git$//')"
user_name="$(basename "$(dirname "$repo_url")")"
repo_identifer="$user_name-$repo_name"
echo "Cloning $repo_url to workspace/$repo_identifer"
git clone --depth=1 "$repo_url" "workspace/$repo_identifer"
if [ ! -d "workspace/$repo_identifer" ]; then
echo "Failed to clone $repo_url"
return
fi
# check oversize
size=$(du -sm "workspace/$repo_identifer" | cut -f1)
echo "Checking size of $repo_identifer: $size MB"
if [[ $size > $SIZE_LIMIT_MB ]]; then
echo "Skipping $repo_identifer due to oversize: $size MB > $SIZE_LIMIT_MB MB"
return
fi
current_path="$(pwd)"
# check last commit date
cd "workspace/$repo_identifer"
last_commit_timestamp="$(git log -1 --format="%cd" --date=format:'%s')"
echo "Checking last commit date of $repo_identifer: $(git log -1 --format="%cd")"
cd "$current_path"
if [ $((CURRENT_TIME - last_commit_timestamp)) -gt $((KEEP_PERIOD_DAYS * 24 * 60 * 60)) ]; then
echo "Skipping $repo_identifer due to outdated: $((CURRENT_TIME - last_commit_timestamp)) > $((KEEP_PERIOD_DAYS * 24 * 60 * 60))"
return
fi
echo "Checking for redtexts in $repo_identifer"
cd "$YGOPRO_SERVER_PATH"
rm expansions || rmdir expansions || true
ln -sf "$current_path/workspace/$repo_identifer" expansions
ls -1 $current_path/workspace/$repo_identifer/*.cdb | xargs -I '{}' sqlite3 '{}' 'select id from datas where type != 0x11 and (type & 0x4000) = 0;' | xargs -I '{}' ./ygopro '{}' 2>&1 | tee "$current_path/dist/redtexts/$repo_identifer.txt"
cd "$current_path"
redtext_line_count=$(wc -l dist/redtexts/$repo_identifer.txt | cut -d' ' -f1)
echo "Finished checking for redtexts in $repo_identifer, $redtext_line_count redtexts found"
if [ $redtext_line_count -gt 0 ]; then
echo "Skipping $repo_identifer due to redtexts"
return
fi
rm dist/redtexts/$repo_identifer.txt
echo "Copying $repo_identifer to dist/$repo_identifer"
ls -1 workspace/$repo_identifer/*.cdb | xargs -I '{}' sqlite3 '{}' .dump | sqlite3 dist/custom-free.cdb || true
# copy strings.conf if necessary
if [ -f workspace/$repo_identifer/strings.conf ]; then
echo "" >> dist/strings.conf
echo "## $repo_identifer" >> dist/strings.conf
cat workspace/$repo_identifer/strings.conf >> dist/strings.conf
fi
cp -rf workspace/$repo_identifer/pics dist/
cp -rf workspace/$repo_identifer/script dist/
echo "Finished processing $repo_identifer"
}
# run for each line in each text in repos/*.txt
for file in repos/*.txt; do
[ -e "$file" ] || continue # 避免 repos 目录为空时报错
while read -r repo_url; do
process_repo "$repo_url"
done < "$file"
done
echo "Finished processing all repos"
echo "Date: $(date)" > dist/version.txt
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment