Skip to content

Auto Check and Update Patch Data #74

Auto Check and Update Patch Data

Auto Check and Update Patch Data #74

Workflow file for this run

name: Auto Check and Update Patch Data
on:
workflow_dispatch:
inputs:
log_level:
description: 'Log Level'
required: false
default: info
check_all:
description: 'Check all item'
required: false
default: false
schedule:
- cron: "0 7 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check FFXIX CN Patch Code Version
id: check_version
run: |
output=$(git ls-remote https://github.com/thewakingsands/ffxiv-datamining-cn |grep "patch" |awk -F "-" '{print $2}'| tail -1)
echo "patch_version=$output" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v3
- name: Compare version from JSON file
id: compare-version
env:
FFXIV_PATCH_VERSION: ${{steps.check_version.outputs.patch_version}}
run: |
if [ $FFXIV_PATCH_VERSION == "$(jq -r '.data' Data/version)" ]; then
echo "No need to update."
else
echo "Need to update."
echo "need_update=true" >> $GITHUB_OUTPUT
fi
- name: Setup Python
if: ${{ steps.compare-version.outputs.need_update == 'true' }}
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
if: ${{ steps.compare-version.outputs.need_update == 'true' }}
run: |
python -m pip install --upgrade pip
pip install requests
- name: Run Python script
id: pull_data
if: ${{ steps.compare-version.outputs.need_update == 'true' }}
env:
FFXIV_PATCH_VERSION: ${{steps.check_version.outputs.patch_version}}
CHECK_ALL: ${{ github.event.inputs.check_all }}
LOG_LEVEL: ${{ github.event.inputs.log_level }}
run: |
python format_item.py
echo "need_push_code=true" >> $GITHUB_OUTPUT
working-directory: Data
- name: Configure Git user
if: ${{ steps.pull_data.outputs.need_push_code == 'true' }}
run: |
git config --global user.name 'Naga Resst'
git config --global user.email '[email protected]'
- name: Check Have Files Been Changed
id: check_diff
if: ${{ steps.pull_data.outputs.need_push_code == 'true' }}
run: |
echo "check_diff=$(git diff --staged --name-status | wc -l)" >> $GITHUB_OUTPUT
- name: Push Code to Repo
if : ${{ steps.check_diff.outputs.check_diff != '0' }}
uses: devops-infra/action-commit-push@master
with:
github_token: "${{ secrets.GIT_KEY }}"
commit_message: "Automatic commit: Update Item Data"
- name: Trigger Push Data to OSS Workflow
if : ${{ steps.check_diff.outputs.check_diff != '0' }}
uses: benc-uk/workflow-dispatch@v1
with:
workflow: push-data.yaml
inputs: '{"force_upload": "true"}'