Process VNDB Data #433
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: Process VNDB Data | |
on: | |
schedule: | |
- cron: "0 */12 * * *" # 每6小时触发一次 | |
workflow_dispatch: # 手动触发 | |
permissions: | |
contents: write | |
actions: write | |
jobs: | |
vndb-process: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install zstandard requests | |
- name: Download and extract VNDB dump | |
run: | | |
python script/dlvndb.py | |
- name: Process vn_data_json JSON data | |
run: | | |
python script/vn_data_json.py | |
- name: Process tagzh.py | |
run: | | |
python script/tagzh.py | |
- name: Process tags JSON data | |
run: | | |
python script/tags.py | |
- name: Process tags_vn JSON data | |
run: | | |
python script/tags_vn_json.py | |
- name: Upload vn_data.ndjson to GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Define variables | |
RELEASE_TAG="v1.0.0" | |
FILE_PATH="vn_data.ndjson" | |
FILE_NAME="vndb-data-Latest.ndjson" | |
REPO="youyou-sudo/vndb-search-datas" | |
# Get the release ID | |
RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/tags/$RELEASE_TAG" | jq -r '.id') | |
# Get the asset ID for the old file | |
ASSET_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/$RELEASE_ID/assets" | jq -r '.[] | select(.name == "'"$FILE_NAME"'") | .id') | |
# Delete the old file | |
if [ "$ASSET_ID" != "null" ]; then | |
curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/assets/$ASSET_ID" | |
fi | |
# Upload the new file | |
RESPONSE=$(curl -s -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @"$FILE_PATH" \ | |
"https://uploads.github.com/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILE_NAME") | |
echo "Response: $RESPONSE" | |
- name: Upload otherPageRules_output.json | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Define variables | |
RELEASE_TAG="v1.0.0" | |
FILE_PATH="otherPageRules_output.json" | |
FILE_NAME="otherPageRules_output.json" | |
REPO="youyou-sudo/vndb-search-datas" | |
# Get the release ID | |
RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/tags/$RELEASE_TAG" | jq -r '.id') | |
# Get the asset ID for the old file | |
ASSET_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/$RELEASE_ID/assets" | jq -r '.[] | select(.name == "'"$FILE_NAME"'") | .id') | |
# Delete the old file | |
if [ "$ASSET_ID" != "null" ]; then | |
curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/assets/$ASSET_ID" | |
fi | |
# Upload the new file | |
RESPONSE=$(curl -s -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @"$FILE_PATH" \ | |
"https://uploads.github.com/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILE_NAME") | |
echo "Response: $RESPONSE" | |
- name: Upload tags.ndjson to GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Define variables | |
RELEASE_TAG="v1.0.0" | |
FILE_PATH="tags.ndjson" | |
FILE_NAME="tags.ndjson" | |
REPO="youyou-sudo/vndb-search-datas" | |
# Get the release ID | |
RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/tags/$RELEASE_TAG" | jq -r '.id') | |
# Get the asset ID for the old file | |
ASSET_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/$RELEASE_ID/assets" | jq -r '.[] | select(.name == "'"$FILE_NAME"'") | .id') | |
# Delete the old file | |
if [ "$ASSET_ID" != "null" ]; then | |
curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/assets/$ASSET_ID" | |
fi | |
# Upload the new file | |
RESPONSE=$(curl -s -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @"$FILE_PATH" \ | |
"https://uploads.github.com/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILE_NAME") | |
echo "Response: $RESPONSE" | |
- name: Upload tags_vn.ndjson to GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Define variables | |
RELEASE_TAG="v1.0.0" | |
FILE_PATH="tags_vn.ndjson" | |
FILE_NAME="tags_vn.ndjson" | |
REPO="youyou-sudo/vndb-search-datas" | |
# Get the release ID | |
RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/tags/$RELEASE_TAG" | jq -r '.id') | |
# Get the asset ID for the old file | |
ASSET_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/$RELEASE_ID/assets" | jq -r '.[] | select(.name == "'"$FILE_NAME"'") | .id') | |
# Delete the old file | |
if [ "$ASSET_ID" != "null" ]; then | |
curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/assets/$ASSET_ID" | |
fi | |
# Upload the new file | |
RESPONSE=$(curl -s -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @"$FILE_PATH" \ | |
"https://uploads.github.com/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILE_NAME") | |
echo "Response: $RESPONSE" | |
- name: Upload timeVersion.ndjson to GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Define variables | |
RELEASE_TAG="v1.0.0" | |
FILE_PATH="timeVersion.ndjson" | |
FILE_NAME="timeVersion.ndjson" | |
REPO="youyou-sudo/vndb-search-datas" | |
# Get the release ID | |
RELEASE_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/tags/$RELEASE_TAG" | jq -r '.id') | |
# Get the asset ID for the old file | |
ASSET_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/$RELEASE_ID/assets" | jq -r '.[] | select(.name == "'"$FILE_NAME"'") | .id') | |
# Delete the old file | |
if [ "$ASSET_ID" != "null" ]; then | |
curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/releases/assets/$ASSET_ID" | |
fi | |
# Upload the new file | |
RESPONSE=$(curl -s -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @"$FILE_PATH" \ | |
"https://uploads.github.com/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILE_NAME") | |
echo "Response: $RESPONSE" |