Skip to content

Commit 6afd6da

Browse files
committed
refactor: 重构课程结构,完善内容和配置
1 parent 5a549b6 commit 6afd6da

474 files changed

Lines changed: 15068 additions & 31919 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

4 KB
Binary file not shown.

.github/workflows/deploy.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Deploy Courses to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
env:
23+
RENV_PATHS_ROOT: ~/.local/share/renv
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Quarto
30+
uses: quarto-dev/quarto-actions/setup@v2
31+
with:
32+
version: '1.4'
33+
34+
- name: Setup R
35+
uses: r-lib/actions/setup-r@v2
36+
with:
37+
r-version: '4.3.0'
38+
use-public-rspm: true
39+
40+
- name: Cache R packages
41+
uses: actions/cache@v3
42+
with:
43+
path: ${{ env.RENV_PATHS_ROOT }}
44+
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
45+
restore-keys: |
46+
${{ runner.os }}-renv-
47+
48+
- name: Install R dependencies
49+
run: |
50+
install.packages(c(
51+
"rmarkdown",
52+
"knitr",
53+
"ggplot2",
54+
"dplyr",
55+
"tidyr",
56+
"readr",
57+
"DT",
58+
"reticulate"
59+
))
60+
shell: Rscript {0}
61+
62+
- name: Render root website
63+
run: |
64+
echo "Rendering root website..."
65+
quarto render index.qmd
66+
67+
- name: Render courses
68+
run: |
69+
# 查找所有课程目录(包含_quarto.yml的子目录)
70+
for course in r-and-rmarkdown; do
71+
if [ -d "$course" ] && [ -f "$course/_quarto.yml" ]; then
72+
echo "Rendering course: $course"
73+
cd "$course"
74+
quarto render
75+
cd ..
76+
fi
77+
done
78+
79+
- name: Organize build output
80+
run: |
81+
# 创建统一的_site目录
82+
mkdir -p _site
83+
84+
# 复制根目录构建结果
85+
if [ -f "index.html" ]; then
86+
cp index.html _site/
87+
fi
88+
89+
# 复制根目录其他文件
90+
for file in license.html resources.html syllabus.html robots.txt sitemap.xml search.json; do
91+
if [ -f "$file" ]; then
92+
cp "$file" _site/
93+
fi
94+
done
95+
96+
# 复制样式和库
97+
if [ -d "site_libs" ]; then
98+
cp -r site_libs _site/
99+
fi
100+
if [ -d "styles" ]; then
101+
cp -r styles _site/
102+
fi
103+
if [ -d "logo" ]; then
104+
cp -r logo _site/
105+
fi
106+
107+
# 复制各课程构建结果
108+
for course in r-and-rmarkdown; do
109+
if [ -d "$course/_site" ]; then
110+
echo "Copying $course to _site/"
111+
mkdir -p "_site/$course"
112+
cp -r "$course/_site"/* "_site/$course/"
113+
# 确保logo在课程目录中
114+
if [ -f "logo/csu_logo.png" ]; then
115+
cp "logo/csu_logo.png" "_site/$course/"
116+
fi
117+
fi
118+
done
119+
120+
echo "Build complete. Site structure:"
121+
ls -la _site/
122+
123+
- name: Setup Pages
124+
uses: actions/configure-pages@v4
125+
126+
- name: Upload artifact
127+
uses: actions/upload-pages-artifact@v3
128+
with:
129+
path: ./_site
130+
131+
deploy:
132+
environment:
133+
name: github-pages
134+
url: ${{ steps.deployment.outputs.page_url }}
135+
runs-on: ubuntu-latest
136+
needs: build
137+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
138+
139+
steps:
140+
- name: Deploy to GitHub Pages
141+
id: deployment
142+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Quarto / R Markdown
2+
_site/
3+
/.quarto/
4+
*_files/
5+
6+
# R
7+
.Rhistory
8+
.Rapp.history
9+
.RData
10+
.Ruserdata
11+
*.Rproj
12+
.Rproj.user/
13+
.renv/
14+
renv.lock
15+
16+
# Python
17+
__pycache__/
18+
*.py[cod]
19+
*$py.class
20+
.Python
21+
venv/
22+
.env/
23+
24+
# macOS
25+
.DS_Store
26+
.AppleDouble
27+
.LSOverride
28+
29+
# IDE
30+
.idea/
31+
.vscode/
32+
*.swp
33+
*.swo
34+
*~
35+
36+
# Temporary files
37+
*.tmp
38+
*.log
39+
*.bak
40+
41+
# Output files (keep source only)
42+
*.html
43+
*.pdf
44+
*.docx
45+
!slides/*.html # Keep rendered slides
46+
47+
# Data (large files)
48+
*.csv
49+
*.tsv
50+
*.xlsx
51+
*.rds
52+
*.rda
53+
*.RData
54+
!data/*.csv # Keep small example data
55+
56+
**/*.quarto_ipynb

0 commit comments

Comments
 (0)