From 0eca0046b36a84df083984ae3eda2c96a2702d23 Mon Sep 17 00:00:00 2001 From: yuanzhen869 Date: Thu, 19 Dec 2024 07:55:46 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/sync=5Fra?= =?UTF-8?q?w=5Ffile.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/sync_raw_file.yml | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/sync_raw_file.yml b/.gitea/workflows/sync_raw_file.yml index cf5efcd..62136b8 100644 --- a/.gitea/workflows/sync_raw_file.yml +++ b/.gitea/workflows/sync_raw_file.yml @@ -11,7 +11,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone Gitea repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # 使用最新版本的 checkout + + - name: Debug current directory and contents + run: | + echo "Current working directory: $(pwd)" + echo "Contents of ./rule directory before cleaning:" + ls -al ./rule # 输出 ./rule 目录的内容,便于检查 - name: Define file types and download run: | @@ -28,10 +34,13 @@ jobs: # 为每个平台类型创建对应目录 save_dir="./rule/${platform_type}" - # 清空平台目录中的所有文件 - rm -rf "$save_dir/*" # 删除目录下的所有文件 + # 检查并删除已存在的目录 + if [ -d "$save_dir" ]; then + echo "Deleting existing directory: $save_dir" + rm -rf "$save_dir" # 删除目录及其内容 + fi - # 如果目录不存在,创建目录 + # 重新创建目录 mkdir -p "$save_dir" # 获取当前平台类型的扩展名 @@ -43,14 +52,27 @@ jobs: url="https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/${platform_type}/${directory}/${directory}.${filetype}" # 使用 curl 下载文件并保存到动态路径 + echo "Downloading $url to $save_dir/${directory}.${filetype}" curl -o "$save_dir/${directory}.${filetype}" "$url" done done + - name: Debug contents after download + run: | + echo "Contents of ./rule directory after download:" + ls -al ./rule # 输出 ./rule 目录的内容,检查文件是否成功下载 + - name: Commit and push changes to Gitea run: | + # 设置 Git 配置信息 git config --global user.name "yuanzhen869" git config --global user.email "yuanzhen869@gmail.com" + + # 确保目录和文件已经更新 git add . # 添加所有更改的文件 + + # 提交更改 git commit -m "Sync files from GitHub raw" || echo "No changes to commit" + + # 推送更改到 Gitea 仓库 git push origin main \ No newline at end of file