Skip to content

[同步]:datasets/mnist #12

[同步]:datasets/mnist

[同步]:datasets/mnist #12

Workflow file for this run

name: 处理数据同步 Issue
on:
issues:
types: [opened, reopened]
jobs:
sync_data:
runs-on: ubuntu-latest
if: contains(github.event.issue.labels.*.name, 'sync')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 解析 Issue 正文
id: parse_body
run: |
cat >parse_issue_body.py <<'EOF'
import os
import re
import sys
# 假设正文通过命令行参数传入
issue_body = sys.argv[1]
# 使用正则表达式匹配所需的参数
sync_type_match = re.search(r'### 同步类型\s*\n\s*(\w+)', issue_body)
source_url_match = re.search(r'### 源地址\s*\n\s*([\w/:-]+)', issue_body)
target_path_match = re.search(r'### 目标路径\s*\n\s*([\w/:-]+)', issue_body)
# 提取参数
sync_type = sync_type_match.group(1) if sync_type_match else ""
source_url = source_url_match.group(1) if source_url_match else ""
target_path = target_path_match.group(1) if target_path_match else ""
# 打印以便后续步骤使用
print(f"::set-output name=sync_type::{sync_type}")
print(f"::set-output name=source_url::{source_url}")
print(f"::set-output name=target_path::{target_path}")
EOF
python parse_issue_body.py "${{ github.event.issue.body }}"
shell: bash
- name: 执行同步脚本
if: ${{ steps.parse_body.outputs.sync_type == 'huggingface' }}
run: |
pip install -r requirements.txt
bash ./sync_hf.sh "${{ steps.parse_body.outputs.source_url }}" "${{ steps.parse_body.outputs.target_path }}"
env:
QUNIU_ACCESS_TOKEN: ${{ secrets.QUNIU_ACCESS_TOKEN }}
QUNIU_SECRET_KEY: ${{ secrets.QUNIU_SECRET_KEY }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
- name: 添加 Issue 评论
uses: actions/github-script@v5
with:
script: |
const output = `同步完成。\n源地址:${{ steps.parse_body.outputs.source_url }}\n下载地址:http://baize-ai.daocloud.io/${{ steps.parse_body.outputs.target_path }}\n`
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
state: 'closed'
});