Files
MaaAssistantArknights/.github/workflows/res-update-game.yml
dependabot[bot] 01a864650a ci: bump github actions versions (#9859)
Updates `softprops/action-gh-release` from 1 to 2
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2)

Updates `peter-evans/create-pull-request` from 5 to 6
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/v5...v6)

Updates `kentaro-m/auto-assign-action` from 1.2.5 to 2.0.0
- [Release notes](https://github.com/kentaro-m/auto-assign-action/releases)
- [Commits](https://github.com/kentaro-m/auto-assign-action/compare/v1.2.5...v2.0.0)

Updates `andymckay/cancel-action` from 0.3 to 0.5
- [Release notes](https://github.com/andymckay/cancel-action/releases)
- [Commits](https://github.com/andymckay/cancel-action/compare/0.3...0.5)


Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Constrat <56174894+Constrat@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-22 14:41:37 +01:00

299 lines
10 KiB
YAML

name: res-update-game
on:
schedule:
- cron: "*/20 * * * *"
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
env:
GH_TOKEN: ${{ secrets.MAA_RESOURCE_SYNC }}
steps:
- name: Clone ArknightsGameResource for Official
uses: actions/checkout@v4
with:
show-progress: false
repository: yuanyan3060/ArknightsGameResource
ref: main
path: ./Official
fetch-depth: 1
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.3.4
with:
name: official
path: ./Official
clone-resources-overseas:
if: github.repository_owner == 'MaaAssistantArknights'
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
steps:
- name: Clone ArknightsGameResource_Yostar for Overseas
uses: actions/checkout@v4
with:
show-progress: false
repository: Kengxxiao/ArknightsGameData_Yostar
ref: main
path: ./Overseas
fetch-depth: 1
sparse-checkout-cone-mode: false
sparse-checkout: |
/en_US/gamedata/excel/item_table.json
/en_US/gamedata/excel/building_data.json
/en_US/gamedata/excel/range_table.json
/en_US/gamedata/excel/character_table.json
/en_US/gamedata/excel/gacha_table.json
/en_US/gamedata/excel/roguelike_topic_table.json
/en_US/gamedata/excel/activity_table.json
/ja_JP/gamedata/excel/item_table.json
/ja_JP/gamedata/excel/building_data.json
/ja_JP/gamedata/excel/range_table.json
/ja_JP/gamedata/excel/character_table.json
/ja_JP/gamedata/excel/gacha_table.json
/ja_JP/gamedata/excel/roguelike_topic_table.json
/ja_JP/gamedata/excel/activity_table.json
/ko_KR/gamedata/excel/item_table.json
/ko_KR/gamedata/excel/building_data.json
/ko_KR/gamedata/excel/range_table.json
/ko_KR/gamedata/excel/character_table.json
/ko_KR/gamedata/excel/gacha_table.json
/ko_KR/gamedata/excel/roguelike_topic_table.json
/ko_KR/gamedata/excel/activity_table.json
- name: Upload Official
uses: actions/upload-artifact@v4.3.4
with:
name: overseas
path: ./Overseas
clone-resources-txwy:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
steps:
- name: Clone arknights-toolbox-update for Taiwan
uses: actions/checkout@v4
with:
show-progress: false
repository: arkntools/arknights-toolbox-update
ref: data-tw
path: ./excel
fetch-depth: 1
token: ${{ secrets.ARKNTOOLS_MAA_RESOURCE_UPDATER}}
- name: Upload Official
uses: actions/upload-artifact@v4.3.4
with:
name: txwy
path: ./excel
update-game-resources:
if: github.repository_owner == 'MaaAssistantArknights'
runs-on: windows-latest
env:
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
steps:
- name: Echo Authenticated User
id: user_info
uses: actions/github-script@v7
with:
github-token: ${{ secrets.MAA_RESOURCE_SYNC }}
script: |
const { data: user } = await github.rest.users.getAuthenticated();
const { data: public_email } = await github.rest.users.listPublicEmailsForAuthenticatedUser();
const username = user.name;
const email = (public_email && public_email[0].email) || `${user.id}+${user.login}@users.noreply.github.com`
console.log(`username: ${username}`);
console.log(`email: ${email}`);
core.setOutput('username', username)
core.setOutput('email', email)
- name: Checkout MAA
uses: actions/checkout@v4
with:
show-progress: false
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
- name: Restore ResourceUpdater.exe from cache
id: cache-resupd
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-resource-updater-main-cpp-${{ hashFiles('./tools/ResourceUpdater/main.cpp') }}
path: |
./tools/ResourceUpdater/x64/Release/opencv_world4_maa.dll
./tools/ResourceUpdater/x64/Release/ResourceUpdater.exe
- name: Bootstrap MaaDeps
if: steps.cache-resupd.outputs.cache-hit != 'true'
run: |
python3 maadeps-download.py x64-windows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add msbuild to PATH
if: steps.cache-resupd.outputs.cache-hit != 'true'
uses: microsoft/setup-msbuild@v2
- name: Build Resource Updater
if: steps.cache-resupd.outputs.cache-hit != 'true'
run: |
MSBUILD tools/ResourceUpdater/ResourceUpdater.vcxproj /t:rebuild /p:Configuration="Release" /p:Platform="x64" /p:BuildProjectReferences=false /m
- name: Save ResourceUpdater.exe to cache
if: always() && steps.cache-resupd.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-resource-updater-main-cpp-${{ hashFiles('./tools/ResourceUpdater/main.cpp') }}
path: |
./tools/ResourceUpdater/x64/Release/opencv_world4_maa.dll
./tools/ResourceUpdater/x64/Release/ResourceUpdater.exe
- name: Download txwy
uses: actions/download-artifact@v4.1.8
with:
name: txwy
path: ./tools/ResourceUpdater/x64/Release/Overseas/zh_TW/gamedata/excel
- name: Download Overseas
uses: actions/download-artifact@v4.1.8
with:
name: overseas
path: ./tools/ResourceUpdater/x64/Release/Overseas
- name: Download Official
uses: actions/download-artifact@v4.1.8
with:
name: official
path: ./tools/ResourceUpdater/x64/Release/Official
- name: Run Resource Updater
run: |
./tools/ResourceUpdater/x64/Release/ResourceUpdater.exe
- name: Task Sorting
run: |
python3 tools/TaskSorter/TaskSorter.py
- name: Cache Prettier
id: cache-prettier
uses: actions/cache@v4
with:
key: ${{ runner.os }}-prettier
path: ./node_modules
- name: Install Prettier
if: steps.cache-prettier.outputs.cache-hit != 'true'
run: |
npm i prettier --no-save
- name: Run Prettier on modified Jsons
run: |
Invoke-Expression "npx prettier -w $(git diff --name-only --diff-filter=ACM 2>$null | Where-Object { $_ -match '\.json$' })"
- name: Check if only sorted
id: check_only_sorted
run: |
git status
$diff = $(git diff --numstat HEAD 2>$null | findstr -i resource)
if ($LASTEXITCODE -ne 0) {
echo "no diff"
exit 0
}
echo "diff: "$diff
$sp = $($diff -split "\s+")
$numbers = $($sp | Where-Object { $_ -match "^\d+$" })
echo "numbers: "$numbers
$length = $numbers.Length
$noDiff = $true
for ($i = 0; $i -lt $length; $i += 2) {
$firstNumber = $numbers[$i]
$secondNumber = $numbers[$i+1]
if ($firstNumber -gt 1) {
$noDiff = $false
break
}
if ($firstNumber -ne $secondNumber) {
$noDiff = $false
break
}
}
echo "noDiff: "$noDiff
echo "only_sorted=$noDiff" >> $env:GITHUB_OUTPUT
- name: Cancelling
if: steps.check_only_sorted.outputs.only_sorted == 'True'
uses: andymckay/cancel-action@0.5
- name: Add files to git
if: steps.check_only_sorted.outputs.only_sorted != 'True'
id: add_files
run: |
git status
git config user.name "${{ steps.user_info.outputs.username }}"
git config user.email "${{ steps.user_info.outputs.email }}"
git add .
$commit_msg = "${{ github.event.inputs.commit_message }}"
if (-not [string]::IsNullOrWhiteSpace($commit_msg)) {
$commit_msg = $commit_msg.Trim()
} else {
$commit_msg = "chore: Auto Update Game Resources - $(Get-Date -Format 'yyyy-MM-dd')"
}
git commit -m "$commit_msg" -m "[skip changelog]"
if ($LASTEXITCODE -eq 0) {
echo "have_commits=True" >> $env:GITHUB_OUTPUT
}
git pull origin $(git rev-parse --abbrev-ref HEAD) --unshallow --rebase
- name: Cancelling
if: steps.add_files.outputs.have_commits != 'True'
uses: andymckay/cancel-action@0.5
- name: Push changes # push the output folder to your repo
if: steps.add_files.outputs.have_commits == 'True'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.MAA_RESOURCE_SYNC }}
- name: Update OTA resource
if: steps.add_files.outputs.have_commits == 'True'
run: |
gh workflow --repo MaaAssistantArknights/MaaRelease run update-resource.yml
# - 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"
# env:
# GH_TOKEN: ${{ github.token }}