-
Notifications
You must be signed in to change notification settings - Fork 3
90 lines (79 loc) · 2.79 KB
/
auto-update.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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"}'