Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: checkout old version #43

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,31 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: ["1.5.0"] # 定义版本数组
steps:
- uses: actions/checkout@v3
- name: Checkout linglong ${{ matrix.version }}
uses: actions/checkout@v4
with:
ref: ${{ matrix.version }} # 使用矩阵中的版本号作为检出的ref
path: ${{ matrix.version }} # 每个版本检出到不同的目录
repository: OpenAtomFoundation/linglong
sparse-checkout: |
docs/pages
sparse-checkout-cone-mode: false
- name: Checkout linglong old version
run: |
# 定义版本和 commit 的映射关系
declare -A dict=(
["1.5.0"]="317ef66813e413adafeae5b01186b34eda514248"
# 添加更多的版本和 commit
)
Comment on lines +22 to +26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider externalizing the version-commit mapping.

The version-commit mapping is hardcoded in the script. Consider externalizing it to a configuration file or environment variable for easier maintenance.

- run: |
    declare -A dict=(
        ["1.5.0"]="317ef66813e413adafeae5b01186b34eda514248"
        # 添加更多的版本和 commit
    )

# 遍历字典并检出每个 commit 到对应的目录
for version in "${!dict[@]}"; do
commit="${dict[$version]}"
# 克隆仓库到指定版本的目录下,使用一个临时分支名
git clone https://github.com/OpenAtomFoundation/linglong.git $version
cd $version
git sparse-checkout init
git sparse-checkout set docs/pages/en docs/pages/guide
git checkout $commit
mv docs/pages/en .
mv docs/pages/guide .
# 输出目录内容,确认文件是否被正确检出
cd ..
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout linglong release
uses: actions/checkout@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .vitepress/theme/versions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function generateVersions() {
const versions = ['']; // 保留空用来判断默认路由
const versions = ['', '1.5.0']; // 保留空用来判断默认路由
return {
defaultVersion: '1.5.0', // 默认显示版本号
defaultVersion: '1.5.6', // 默认显示版本号
versions: versions
};
}
Loading