-
Notifications
You must be signed in to change notification settings - Fork 6
139 lines (120 loc) · 5.4 KB
/
Copy pathupdate-modelscope-docs.yml
File metadata and controls
139 lines (120 loc) · 5.4 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Update ModelScope Documentation
on:
# Scheduled trigger (daily at 18:00 UTC, which is 02:00 Beijing Time next day)
schedule:
- cron: '0 3 * * *'
# Manual trigger (run via GitHub web interface)
workflow_dispatch:
# Trigger when model_list.txt or workflow files change
push:
paths:
- 'docs/flagrelease_en/model_list.txt'
- '.github/workflows/update-modelscope-docs.yml'
- 'docs/scripts/download_readmes.py'
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository code
uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch full history for proper git diff
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: Install Python dependencies
run: |
pip install -r requirements.txt
- name: Generate model list
run: |
cd "$GITHUB_WORKSPACE"
python docs/scripts/generate_model_list.py
continue-on-error: true
- name: Download ModelScope documentation
id: download
run: |
cd "$GITHUB_WORKSPACE"
python docs/scripts/download_readmes.py
continue-on-error: true # Continue even if some downloads fail
- name: Generate download report
id: generate-report
run: |
# Create a detailed download report file with success and failure information
# Store the report file in a tem directory to prevent it from pusing to the repo
REPORT_FILE="/tmp/download_report_$(TZ='Asia/Shanghai' date +'%Y%m%d_%H%M%S').txt"
echo "# ModelScope Documentation Update Report" > $REPORT_FILE
echo "## Generated on: $(TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M:%S %Z')" >> $REPORT_FILE
echo "## Workflow Run: [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $REPORT_FILE
echo "" >> $REPORT_FILE
# Count the number of updated files
if [ -d "docs/flagrelease_en/model_readmes/" ]; then
CHANGED_COUNT=$(git diff --name-only docs/flagrelease_en/model_readmes/ 2>/dev/null | wc -l || echo "0")
echo "## Summary" >> $REPORT_FILE
echo "- **Total changes detected:** $CHANGED_COUNT files" >> $REPORT_FILE
echo "" >> $REPORT_FILE
if [ "$CHANGED_COUNT" -gt 0 ]; then
echo "## Changed Files" >> $REPORT_FILE
git diff --name-only docs/flagrelease_en/model_readmes/ | while read file; do
echo "- $file" >> $REPORT_FILE
done
echo "" >> $REPORT_FILE
fi
fi
# Extract statistics from script output if available
echo "## Model Download Statistics" >> $REPORT_FILE
echo "- **Last run status:** ${{ job.status }}" >> $REPORT_FILE
echo "- **Trigger type:** ${{ github.event_name }}" >> $REPORT_FILE
if [ "${{ github.event_name }}" = "schedule" ]; then
echo "- **Schedule:** Daily at 03:00 UTC (11:00 Beijing Time)" >> $REPORT_FILE
fi
echo "" >> $REPORT_FILE
echo "## Next Steps" >> $REPORT_FILE
echo "Please review the changes in the model documentation files above." >> $REPORT_FILE
echo "After merging this PR, the documentation will be updated on the main branch." >> $REPORT_FILE
echo "report_file=$REPORT_FILE" >> $GITHUB_OUTPUT
- name: Check for file changes
id: check-changes
run: |
# Check if any files have been modified or added
git add -N .
# Exclude the report file
if git diff --quiet docs/flagrelease_en/model_readmes/ 2>/dev/null; then
echo "No file changes detected"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "File changes detected"
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Reset git configuration before creating PR
if: steps.check-changes.outputs.has_changes == 'true'
run: |
# clear
git config --local --unset-all http.https://github.com/.extraheader 2>/dev/null || true
git config --global --unset-all http.https://github.com/.extraheader 2>/dev/null || true
- name: Generate branch name
id: branch-name
if: steps.check-changes.outputs.has_changes == 'true'
run: |
BRANCH_NAME="update/modelscope-docs-$(TZ='Asia/Shanghai' date +'%Y%m%d-%H%M%S')"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "Generated branch name: $BRANCH_NAME"
- name: Create Pull Request
if: steps.check-changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Auto-update ModelScope documentation [$(TZ=''Asia/Shanghai'' date +''%Y-%m-%d %H:%M'')]'
branch: ${{ steps.branch-name.outputs.branch_name }}
delete-branch: true
title: 'ModelScope Documentation Update - $(TZ=''Asia/Shanghai'' date +''%Y-%m-%d %H:%M'')'
body-path: ${{ steps.generate-report.outputs.report_file }}
base: 'main'
labels: 'documentation, auto-update, modelscope'
draft: false
# Exclude the report file
paths: |
docs/flagrelease_en/model_readmes/*.md
docs/flagrelease_en/model_list.txt