Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用Action触发一次推送 #2

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
68717c0
Create auto.yml
hsyhhssyy Dec 6, 2024
ae49404
Merge pull request #1 from hsyhhssyy/hsyhhssyy-patch-1
hsyhhssyy Dec 6, 2024
c915d1f
Update auto.yml
hsyhhssyy Dec 6, 2024
00c77e2
Update auto.yml
hsyhhssyy Dec 6, 2024
d66ade3
Update auto.yml
hsyhhssyy Dec 6, 2024
0310341
Update auto.yml
hsyhhssyy Dec 6, 2024
0f91b87
Update auto.yml
hsyhhssyy Dec 6, 2024
b61cba6
Update auto.yml
hsyhhssyy Dec 6, 2024
4471f83
Update gamedata.json
hsyhhssyy Dec 6, 2024
fe21b29
Update baidu.json
hsyhhssyy Dec 6, 2024
aa72957
Update auto.yml
hsyhhssyy Dec 6, 2024
5525a2f
Merge pull request #2 from hsyhhssyy/hsyhhssyy-patch-2
hsyhhssyy Dec 6, 2024
286ea4e
Update auto.yml
hsyhhssyy Dec 6, 2024
4e4db08
Update auto.yml
hsyhhssyy Dec 6, 2024
b65f09d
Update auto.yml
hsyhhssyy Dec 6, 2024
660e988
Update auto.yml
hsyhhssyy Dec 6, 2024
c8af7b7
Update auto.yml
hsyhhssyy Dec 6, 2024
7151b8c
Create Kengxxiao_last_commit.txt
hsyhhssyy Dec 6, 2024
01fbd4f
Update auto.yml
hsyhhssyy Dec 6, 2024
029ee1a
Delete .github/workflows/Kengxxiao_last_commit.txt
hsyhhssyy Dec 6, 2024
38cba5b
Update auto.yml
hsyhhssyy Dec 6, 2024
5b7acad
Create check_external.yml
hsyhhssyy Dec 6, 2024
678d659
Update check_external.yml
hsyhhssyy Dec 6, 2024
19fa155
Update check_external.yml
hsyhhssyy Dec 6, 2024
fd4cc1e
Update auto.yml
hsyhhssyy Dec 6, 2024
dd16f02
Update check_external.yml
hsyhhssyy Dec 6, 2024
7dc3e78
Update check_external.yml
hsyhhssyy Dec 6, 2024
0f7279c
Update auto.yml
hsyhhssyy Dec 6, 2024
7cb5b39
Update check_external.yml
hsyhhssyy Dec 6, 2024
345c61e
Update auto.yml
hsyhhssyy Dec 6, 2024
ae9f156
Update check_external.yml
hsyhhssyy Dec 6, 2024
2fcb0b7
Update kengxxiao_last_commit.txt with new SHA: d9f0aa7976467d5b7244f7…
github-actions[bot] Dec 6, 2024
f9ba746
Update check_external.yml
hsyhhssyy Dec 6, 2024
7f53609
Update auto.yml
hsyhhssyy Dec 6, 2024
8aeacd2
Update kengxxiao_last_commit.txt
hsyhhssyy Dec 6, 2024
86b640a
Update kengxxiao_last_commit.txt with new SHA: a48ec0c92fafc1d1e52e8a…
github-actions[bot] Dec 6, 2024
0573451
Update kengxxiao_last_commit.txt with new SHA: 40a0869e04d79c83f9cbb0…
github-actions[bot] Dec 12, 2024
be9ef4c
Update kengxxiao_last_commit.txt with new SHA: 34ba5a7c7e04ed7a2c7f9a…
github-actions[bot] Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/auto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 同步知识库到百度

on:
push:
branches:
- master
paths-ignore:
- '.github/workflows/**' # 忽略 .github/workflows 目录下的所有更改
- 'kengxxiao_last_commit.txt' # 忽略 kengxxiao_last_commit.txt
workflow_call: # 允许其他workflow触发这个workflow
workflow_dispatch: # 允许手动触发这个workflow

jobs:
setup_and_run:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Generate gamedata.json
run: |
GAMEDATA_ABS_PATH=$(realpath ./gamedata_rep)/zh_CN/gamedata
sed -i "s|\[GameDataPath\]|${GAMEDATA_ABS_PATH}|g" ./config/gamedata.json

- name: Replace [BaiduToken] with secret BAIDU_TOKEN
run: |
sed -i 's|\[BaiduToken\]|${{ secrets.BAIDU_TOKEN }}|g' ./config/baidu.json
env:
BAIDU_TOKEN: ${{ secrets.BAIDU_TOKEN }}

- name: Output JSON files content (for testing)
run: |
echo "Contents of gamedata.json:"
cat ./config/gamedata.json
echo "Contents of baidu.json:"
cat ./config/baidu.json
- name: Install dependencies
run: |
pip install -r requirements.txt

- name: Clone ArknightsGameData repository
run: |
git clone https://github.com/Kengxxiao/ArknightsGameData ./gamedata_rep

- name: Run Python scripts
run: |
python gen_attr.py --single_file
python gen_skill.py --single_file
python gen_character.py --single_file
python gen_story.py --single_file

69 changes: 69 additions & 0 deletions .github/workflows/check_external.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 检查K佬的仓库

on:
schedule:
# - cron: '*/5 * * * *' # 每5分钟触发一次, 测试用频率
- cron: '0 8 * * *' # UTC时间每天08:00,即北京时间16:00
workflow_dispatch: # 允许手动触发此 Workflow

jobs:
check-commit:
runs-on: ubuntu-latest
outputs:
shas_different: ${{ env.shas_different }}

steps:
# 步骤1:检出当前仓库代码
- name: Checkout current repository
uses: actions/checkout@v3
with:
persist-credentials: true

- name: Get latest commit SHA from external repo
id: get_latest
run: |
SHA=$(git ls-remote https://github.com/Kengxxiao/ArknightsGameData.git refs/heads/master | awk '{print $1}')
# 测试用代码,从我的repo检测更改
# SHA=$(git ls-remote https://github.com/hsyhhssyy/RebaseTest.git refs/heads/master | awk '{print $1}')
echo "Latest SHA: $SHA"
echo "sha=$SHA" >> $GITHUB_OUTPUT
shell: bash

- name: Read last commit SHA
id: read_last
run: |
if [ -f kengxxiao_last_commit.txt ]; then
LAST_SHA=$(cat kengxxiao_last_commit.txt)
echo "Last recorded SHA: $LAST_SHA"
else
LAST_SHA=""
echo "No last recorded SHA found."
fi
echo "last_sha=$LAST_SHA" >> $GITHUB_ENV
shell: bash

- name: Compare SHAs
id: compare
run: |
if [ "${{ steps.get_latest.outputs.sha }}" != "${{ env.last_sha }}" ]; then
echo "shas_different=true" >> $GITHUB_ENV
else
echo "shas_different=false" >> $GITHUB_ENV
fi
shell: bash

- name: Update last_commit.txt with new SHA
if: env.shas_different == 'true'
run: |
echo "${{ steps.get_latest.outputs.sha }}" > kengxxiao_last_commit.txt
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add kengxxiao_last_commit.txt
git commit -m "Update kengxxiao_last_commit.txt with new SHA: ${{ steps.get_latest.outputs.sha }}"
git push
shell: bash

trigger-workflow:
needs: check-commit
if: needs.check-commit.outputs.shas_different == 'true'
uses: ./.github/workflows/auto.yml
2 changes: 1 addition & 1 deletion config/baidu.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"appbuilder_token": "",
"appbuilder_token": "[BaiduToken]",
"knowledge_bases": {
"attr": {
"id": "",
Expand Down
2 changes: 1 addition & 1 deletion config/gamedata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"gamedata": "E:\\Production\\amiya-bot\\Amiya-Bot\\resource\\gamedata\\gamedata"
"gamedata": "[GameDataPath]"
}
1 change: 1 addition & 0 deletions kengxxiao_last_commit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
34ba5a7c7e04ed7a2c7f9adc82191335476ed926