فهرست منبع

auto commit and push

Nattiden 2 سال پیش
والد
کامیت
a0d0a27402
2فایلهای تغییر یافته به همراه19 افزوده شده و 3 حذف شده
  1. 12 1
      .github/workflows/check_mcversion.yml
  2. 7 2
      Actions/check_mcv.py

+ 12 - 1
.github/workflows/check_mcversion.yml

@@ -8,6 +8,10 @@ jobs:
    check_mcv:
       runs-on: ubuntu-latest
       steps:
+       - name: 配置 Git 信息
+         run: |
+            git config --local user.email "github-actions[bot]@users.noreply.github.com"
+            git config --local user.name "GitHub Actions"
        - name: 签出储存库
          uses: actions/checkout@v4
        - name: 配置 Python 环境
@@ -19,4 +23,11 @@ jobs:
             python -m pip install --upgrade pip
             pip install requests
        - name: 运行更新脚本
-         run: python Actions/check_mcv.py
+         run: python Actions/check_mcv.py
+         - name: Configure Git
+       - name: 提交更改
+         run: |
+            git add *
+            git diff-index --quiet HEAD || git commit -m "preloaded new version"
+       - name: 推送更改
+         run: git push

+ 7 - 2
Actions/check_mcv.py

@@ -1,4 +1,3 @@
-# https://piston-meta.mojang.com/mc/game/version_manifest.json
 import json
 import requests
 import re
@@ -11,6 +10,8 @@ PRE_RELEASE_PATTERN = re.compile(r'^.*-pre[0-9]+$')
 RELEASE_CANDIDATE_PATTERN = re.compile(r'^.*-rc[0-9]+$')
 RELEASE_PATTERN = re.compile(r'^1\.[0-9]+(\.[0-9]+)?$')
 
+INIT_MARKDOWN = '---\nversion-image-link: https://exapmle.com\nnot_finished: true\n---\n'
+
 def get_version_type(vid:str):
     if re.match(SNAPSHOT_PATTERN,vid):
         return 'Snapshot'
@@ -23,8 +24,12 @@ def get_version_type(vid:str):
     return ''
 
 def update_library(version_libloc:str,ver_type:str,ver_id:str):
-    if os.path.exists(f'{version_libloc}{ver_type}{os.sep}{ver_id}.md'):
+    filepath = f'{version_libloc}{ver_type}{os.sep}{ver_id}.md'
+    if os.path.exists(filepath):
         print(f'- {ver_id:} 已存在于版本库,无需更改') 
+    else:
+        with open(filepath, "w") as file:
+            file.write(INIT_MARKDOWN)
 
 try:
     response = requests.get(LAUNCHER_MANIFSET_URL)