mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-01 01:10:34 +08:00
364 lines
12 KiB
YAML
364 lines
12 KiB
YAML
name: Resource Updater
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "*/20 * * * *" # Runs every 20 minutes
|
|
workflow_dispatch:
|
|
inputs:
|
|
commit_message:
|
|
description: "Commit Message"
|
|
type: string
|
|
required: false
|
|
|
|
jobs:
|
|
clone-resources-official:
|
|
if: github.repository_owner == 'MaaAssistantArknights'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Clone ArknightsGameResource for Official
|
|
uses: actions/checkout@v5
|
|
with:
|
|
show-progress: false
|
|
repository: yuanyan3060/ArknightsGameResource
|
|
ref: main
|
|
path: ./Official
|
|
sparse-checkout-cone-mode: false
|
|
sparse-checkout: |
|
|
/levels.json
|
|
/item
|
|
/building_skill
|
|
/gamedata/excel/item_table.json
|
|
/gamedata/excel/building_data.json
|
|
/gamedata/excel/range_table.json
|
|
/gamedata/excel/character_table.json
|
|
/gamedata/excel/gacha_table.json
|
|
/gamedata/excel/roguelike_topic_table.json
|
|
/gamedata/excel/activity_table.json
|
|
|
|
- name: Upload Official
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: official
|
|
path: ./Official
|
|
compression-level: 0
|
|
|
|
clone-resources-overseas:
|
|
if: github.repository_owner == 'MaaAssistantArknights'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Clone ArknightsGameResource_Yostar for Overseas
|
|
uses: actions/checkout@v5
|
|
with:
|
|
show-progress: false
|
|
repository: ArknightsAssets/ArknightsGamedata
|
|
ref: master
|
|
path: ./Overseas
|
|
sparse-checkout-cone-mode: false
|
|
sparse-checkout: |
|
|
/en/gamedata/excel/item_table.json
|
|
/en/gamedata/excel/building_data.json
|
|
/en/gamedata/excel/range_table.json
|
|
/en/gamedata/excel/character_table.json
|
|
/en/gamedata/excel/gacha_table.json
|
|
/en/gamedata/excel/roguelike_topic_table.json
|
|
/en/gamedata/excel/activity_table.json
|
|
/jp/gamedata/excel/item_table.json
|
|
/jp/gamedata/excel/building_data.json
|
|
/jp/gamedata/excel/range_table.json
|
|
/jp/gamedata/excel/character_table.json
|
|
/jp/gamedata/excel/gacha_table.json
|
|
/jp/gamedata/excel/roguelike_topic_table.json
|
|
/jp/gamedata/excel/activity_table.json
|
|
/kr/gamedata/excel/item_table.json
|
|
/kr/gamedata/excel/building_data.json
|
|
/kr/gamedata/excel/range_table.json
|
|
/kr/gamedata/excel/character_table.json
|
|
/kr/gamedata/excel/gacha_table.json
|
|
/kr/gamedata/excel/roguelike_topic_table.json
|
|
/kr/gamedata/excel/activity_table.json
|
|
|
|
- name: Upload Official
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: overseas
|
|
path: ./Overseas
|
|
compression-level: 0
|
|
|
|
clone-resources-txwy:
|
|
if: github.repository_owner == 'MaaAssistantArknights'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Clone arknights-toolbox-update for Taiwan
|
|
uses: actions/checkout@v5
|
|
with:
|
|
show-progress: false
|
|
repository: arkntools/arknights-toolbox-update
|
|
ref: data-tw
|
|
path: ./excel
|
|
token: ${{ secrets.ARKNTOOLS_MAA_RESOURCE_UPDATER}}
|
|
|
|
- name: Download stages.json from Penguin Stats
|
|
run: |
|
|
cd "./excel"
|
|
|
|
baseUrl="https://penguin-stats.io/PenguinStats/api/v2/stages?server="
|
|
|
|
parameters=("CN" "US" "JP" "KR")
|
|
|
|
for param in "${parameters[@]}"; do
|
|
{
|
|
if curl -s -o "stages_${param}.json" "${baseUrl}${param}"; then
|
|
echo "Successfully fetched data for ${param}"
|
|
else
|
|
echo "Failed to fetch data for ${param}" >&2
|
|
exit 1
|
|
fi
|
|
} &
|
|
done
|
|
wait
|
|
|
|
- name: Upload Official
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: txwy
|
|
path: ./excel
|
|
compression-level: 0
|
|
|
|
update-game-resources:
|
|
# In case of rate limitations on the runners/instances, add dependency, by removing the comment
|
|
|
|
# needs: [clone-resources-official, clone-resources-overseas, clone-resources-txwy]
|
|
if: github.repository_owner == 'MaaAssistantArknights'
|
|
runs-on: macos-latest
|
|
steps:
|
|
- name: Checkout MAA
|
|
uses: actions/checkout@v5
|
|
with:
|
|
# TL;DR https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/9872#issuecomment-2251378371
|
|
# actions/checkout uses ${{ secrets.GITHUB_TOKEN }} by default, meaning all steps will inherit it
|
|
persist-credentials: false # Needed to bypass protection rules in Push changes
|
|
show-progress: false
|
|
fetch-depth: 3
|
|
|
|
- name: Restore ResourceUpdater from cache
|
|
id: resupd-cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
key: ResourceUpdater-${{ runner.os }}-${{ hashFiles('tools/ResourceUpdater/main.cpp') }}
|
|
path: |
|
|
./tools/ResourceUpdater/libopencv_world4.4.11.0.dylib
|
|
./tools/ResourceUpdater/res_updater
|
|
|
|
- name: Cache MaaDeps
|
|
if: steps.resupd-cache.outputs.cache-hit != 'true'
|
|
id: maadeps-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
./MaaDeps
|
|
key: ${{ runner.os }}-arm64-maadeps-${{ hashFiles('tools/maadeps-download.py') }}
|
|
|
|
- name: Bootstrap MaaDeps
|
|
if: steps.resupd-cache.outputs.cache-hit != 'true' && steps.maadeps-cache.outputs.cache-hit != 'true'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
python3 tools/maadeps-download.py arm64-osx
|
|
|
|
- name: Config cmake
|
|
if: steps.resupd-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd tools/ResourceUpdater
|
|
mkdir -p build
|
|
cmake -B build -GNinja \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DMAADEPS_TRIPLET='maa-arm64-osx' \
|
|
-DWITH_HASH_VERSION=ON
|
|
|
|
- name: Build
|
|
if: steps.resupd-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
cmake --build tools/ResourceUpdater/build --config Release --parallel $(sysctl -n hw.logicalcpu)
|
|
|
|
- name: Install
|
|
if: steps.resupd-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
cmake --install tools/ResourceUpdater/build --prefix tools/ResourceUpdater --config Release
|
|
|
|
- name: Save ResourceUpdater to cache
|
|
if: always() && steps.resupd-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
key: ResourceUpdater-${{ runner.os }}-${{ hashFiles('tools/ResourceUpdater/main.cpp') }}
|
|
path: |
|
|
./tools/ResourceUpdater/libopencv_world4.4.11.0.dylib
|
|
./tools/ResourceUpdater/res_updater
|
|
|
|
- name: Download txwy
|
|
id: download-txwy
|
|
uses: actions/download-artifact@v5
|
|
continue-on-error: true
|
|
with:
|
|
name: txwy
|
|
path: ./tools/ResourceUpdater/Overseas/tw/gamedata/excel
|
|
|
|
- name: Delay txwy
|
|
if: steps.download-txwy.outcome == 'failure'
|
|
run: |
|
|
sleep 10
|
|
|
|
- name: Re-download txwy
|
|
if: steps.download-txwy.outcome == 'failure'
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: txwy
|
|
path: ./tools/ResourceUpdater/Overseas/tw/gamedata/excel
|
|
|
|
- name: Download Overseas
|
|
id: download-overseas
|
|
uses: actions/download-artifact@v5
|
|
continue-on-error: true
|
|
with:
|
|
name: overseas
|
|
path: ./tools/ResourceUpdater/Overseas
|
|
|
|
- name: Delay Overseas
|
|
if: steps.download-overseas.outcome == 'failure'
|
|
run: |
|
|
sleep 10
|
|
|
|
- name: Re-download Overseas
|
|
if: steps.download-overseas.outcome == 'failure'
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: overseas
|
|
path: ./tools/ResourceUpdater/Overseas
|
|
|
|
- name: Download Official
|
|
id: download-official
|
|
uses: actions/download-artifact@v5
|
|
continue-on-error: true
|
|
with:
|
|
name: official
|
|
path: ./tools/ResourceUpdater/Official
|
|
|
|
- name: Delay Official
|
|
if: steps.download-official.outcome == 'failure'
|
|
run: |
|
|
sleep 10
|
|
|
|
- name: Re-download Official
|
|
if: steps.download-official.outcome == 'failure'
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: official
|
|
path: ./tools/ResourceUpdater/Official
|
|
|
|
- name: Run Resource Updater
|
|
run: |
|
|
./tools/ResourceUpdater/res_updater
|
|
|
|
- name: Task Sorting
|
|
id: task_sorting
|
|
run: |
|
|
python3 tools/TaskSorter/TaskSorter.py
|
|
echo "gitdiff=$(echo $(git diff --name-only --diff-filter=ACM 2>/dev/null | grep '\.json$'))" >> $GITHUB_OUTPUT
|
|
|
|
- name: Run prettier
|
|
uses: Nerixyz/actionsx-prettier@v3-adj
|
|
with:
|
|
args: -w ${{ steps.task_sorting.outputs.gitdiff }}
|
|
|
|
- name: Update version.json date if necessary
|
|
id: update_version
|
|
run: |
|
|
sh ./tools/ResourceUpdater/version.sh
|
|
|
|
- name: Setup python
|
|
if: steps.update_version.outputs.contains_png == 'True'
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Cache Python packages
|
|
if: always() && steps.update_version.outputs.contains_png == 'True'
|
|
id: cache_python
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ env.pythonLocation }}/Lib/site-packages
|
|
key: ${{ runner.os }}-pip-optimize-templates-${{ hashFiles('./tools/OptimizeTemplates/requirements.txt') }}
|
|
|
|
- name: Install dependencies
|
|
if: steps.cache_python.outputs.cache-hit != 'true' && steps.update_version.outputs.contains_png == 'True'
|
|
run: |
|
|
pip install -r tools/OptimizeTemplates/requirements.txt
|
|
|
|
- name: Setup oxipng
|
|
if: steps.update_version.outputs.contains_png == 'True'
|
|
uses: baptiste0928/cargo-install@v3
|
|
with:
|
|
crate: oxipng
|
|
|
|
- name: Run optimize_templates
|
|
if: steps.update_version.outputs.contains_png == 'True'
|
|
run: |
|
|
python3 tools/OptimizeTemplates/optimize_templates.py -p resource/template/items/ resource/template/infrast/
|
|
|
|
- name: Add files to git
|
|
if: steps.update_version.outputs.changes == 'True'
|
|
id: add_files
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add .
|
|
|
|
commit_msg="${{ github.event.inputs.commit_message }}"
|
|
if [ -z "$commit_msg" ]; then
|
|
commit_msg="chore: Auto Update Game Resources - $(date '+%Y-%m-%d')"
|
|
else
|
|
commit_msg=$(echo "$commit_msg" | xargs) # Trim whitespace
|
|
fi
|
|
|
|
run_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
|
|
|
git commit -m "$commit_msg" -m "$run_url" -m "[skip changelog]"
|
|
if [ $? -eq 0 ]; then
|
|
echo "have_commits=True" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
git pull origin ${{ github.ref_name }} --rebase
|
|
|
|
- name: Push changes
|
|
if: steps.add_files.outputs.have_commits == 'True'
|
|
uses: ad-m/github-push-action@master
|
|
with:
|
|
branch: ${{ github.ref }}
|
|
github_token: ${{ secrets.MAA_RESOURCE_SYNC }}
|
|
|
|
# - name: Update OTA resource
|
|
# if: steps.update_version.outputs.update_resources == 'True'
|
|
# env:
|
|
# GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
|
|
# run: |
|
|
# gh workflow --repo MaaAssistantArknights/MaaRelease run update-resource.yml
|
|
|
|
- name: Add cancelled status
|
|
if: steps.update_version.outputs.changes != 'True' || steps.add_files.outputs.have_commits != 'True'
|
|
uses: andymckay/cancel-action@0.5
|
|
|
|
# - name: Release # ref: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
|
|
# if: steps.add_files.outputs.have_commits == 'True'
|
|
# run: |
|
|
# gh workflow run release-nightly-ota -f release_body="Auto Release of Resource Updates"
|
|
|
|
- name: Create issue if failed
|
|
if: failure()
|
|
uses: actions-cool/issues-helper@v3
|
|
with:
|
|
actions: "create-issue"
|
|
title: "Failed to Update Game Resources"
|
|
body: |
|
|
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
|
|
@MistEO @ABA2396 @Constrat
|