Skip to content

Pull and Process Cataclysm-BN Data #288

Pull and Process Cataclysm-BN Data

Pull and Process Cataclysm-BN Data #288

Workflow file for this run

name: Pull and Process Cataclysm-BN Data
on:
schedule:
- cron: '40 */12 * * *'
workflow_dispatch:
inputs:
target_branch:
description: 'Branch to push data to'
required: false
default: 'main'
type: choice
options:
- main
- dev
jobs:
pull-and-process:
name: Pull Data, Convert GFX, & Precompress
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [24]
permissions:
contents: write
steps:
- name: Checkout action branch
uses: actions/checkout@v6
with:
ref: action
fetch-depth: 1
- name: Checkout data branch
uses: actions/checkout@v6
with:
ref: ${{ inputs.target_branch || 'main' }}
fetch-depth: 1
path: data_workspace
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Fetch Dependencies
run: pnpm install
- name: Pull game data
uses: actions/github-script@v8
env:
DATA_BRANCH: ${{ inputs.target_branch || 'main' }}
WORKSPACE_DIR: data_workspace
with:
script: |
const { default: run } = await import('${{ github.workspace }}/pull-data.mjs')
await run({ github, context })
- name: Install compression tools
run: sudo apt-get update && sudo apt-get install -y webp brotli
- name: Postprocess GFX and JSON
run: node postprocess-data.mjs --workspace=data_workspace
- name: Commit and push all changes
working-directory: data_workspace
run: |
# Check if there are any changes
if [[ -n $(git status --porcelain) ]]; then
echo ""
echo "💾 Committing all changes..."
git config user.name "HHG2CBN Update Bot"
git config user.email "hhg2cbn@users.noreply.github.com"
git add -A
# Create commit message
COMMIT_MSG="Update data, convert GFX, and precompress JSON"
if [ -f builds.json ]; then
LATEST_BUILD=$(jq -r '.[0].build_number' builds.json || echo "null")
if [ "$LATEST_BUILD" != "null" ]; then
COMMIT_MSG="Update data for $LATEST_BUILD"
fi
fi
git commit -m "$COMMIT_MSG"
git push origin HEAD:${{ inputs.target_branch || 'main' }}
echo "✅ Successfully pushed all changes"
else
echo ""
echo "ℹ️ No changes to commit"
fi