Update assets #2564
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: Update assets | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 */4 * * *" | |
jobs: | |
check: | |
runs-on: ubuntu-22.04 | |
outputs: | |
status: ${{ steps.early.outputs.status }} | |
steps: | |
- name: export needed files | |
run: | | |
curl https://raw.githubusercontent.com/akgcc/arkdata/main/cmp_version.py > cmp_version.py | |
curl https://raw.githubusercontent.com/akgcc/arkdata/main/cache/versions.json > versions.json | |
- id: early | |
name: Early exit | |
run: | | |
python cmp_version.py | |
if [ -f "NO_UPDATE_NEEDED" ]; then | |
echo "status=failure" >> $GITHUB_OUTPUT | |
else | |
echo "status=success" >> $GITHUB_OUTPUT | |
fi | |
main: | |
runs-on: ubuntu-22.04 | |
needs: check | |
if: needs.check.outputs.status == 'success' | |
steps: | |
- name: Check for lock file | |
run: | | |
if [ -f ".github/LOCK_FAIL" ]; then | |
echo "Previous run failed, skipping this run." | |
exit 1 | |
fi | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Convert Poetry lockfile | |
run: | | |
pipx install poetry | |
poetry export -f requirements.txt -o requirements.txt --without-hashes | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
- name: Install Python dependencies | |
run: pip install -r requirements.txt | |
- name: Install audio dependencies | |
run: sudo apt-get update && sudo apt-get install -y ffmpeg libogg-dev libvorbis-dev | |
- name: Get FBS definitions | |
run: git clone https://github.com/MooncellWiki/OpenArknightsFBS.git | |
- name: Get flatbuffers | |
run: git clone https://github.com/google/flatbuffers.git | |
- name: Build flatc | |
run: cd ./flatbuffers/CMake && cmake -G "Unix Makefiles" .. && make install DESTDIR=../../ | |
- name: Install modified kawapack | |
run: pip install git+https://github.com/akgcc/kawapack | |
- name: Update config with sounds | |
run: python append_sounds.py | |
- name: Set up Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Set up Rust cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Build app | |
run: cargo build --release | |
- name: Run app | |
env: | |
PYTHONUNBUFFERED: 1 # Ensure Python output is flushed | |
run: ./target/release/arkdata | |
- name: Commit updates | |
run: | | |
git config --global user.name "Kawabot" | |
git config --global user.email "[email protected]" | |
git pull --all | |
git add cache | |
git add assets | |
git diff-index --quiet HEAD || git commit -m "Update data" && git push | |
- name: Update lock file on failure | |
if: failure() | |
run: | | |
# Create the lock file if the task failed | |
git config --global user.name "Kawabot" | |
git config --global user.email "[email protected]" | |
git pull --all | |
echo "Task failed" > .github/LOCK_FAIL | |
git add .github/LOCK_FAIL | |
git diff-index --quiet HEAD || git commit -m "Update failed, create lock file" && git push |