generated from icrdr/omoolab-project
add vitepress and workflow
All checks were successful
Deploy to Aliyun OSS / deploy (push) Successful in 24s
All checks were successful
Deploy to Aliyun OSS / deploy (push) Successful in 24s
This commit is contained in:
81
.github/workflows/deploy.yaml
vendored
Normal file
81
.github/workflows/deploy.yaml
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
name: Deploy to Aliyun OSS
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "wiki-*" # 当推送 wiki-* 开头的 tag 时触发
|
||||
branches:
|
||||
- "main" # 当推送 main 分支时触发
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set variable
|
||||
run: |
|
||||
REPO_NAME=${{ github.event.repository.name }}
|
||||
|
||||
# 判断触发类型
|
||||
if [[ "${{ github.ref_type }}" == "tag" ]]; then
|
||||
# Tag 触发:去掉 "wiki-" 前缀
|
||||
TAG_NAME=${{ github.ref_name }}
|
||||
CLEAN_TAG_NAME=${TAG_NAME#wiki-}
|
||||
BASE_PATH="/$REPO_NAME/$CLEAN_TAG_NAME/"
|
||||
else
|
||||
# Branch 触发:使用仓库名
|
||||
TAG_NAME=""
|
||||
BASE_PATH="/$REPO_NAME/"
|
||||
fi
|
||||
|
||||
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
|
||||
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
|
||||
echo "BASE_PATH=$BASE_PATH" >> $GITHUB_ENV
|
||||
|
||||
echo "Repository: $REPO_NAME"
|
||||
echo "Tag: $TAG_NAME"
|
||||
echo "Base path: $BASE_PATH"
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Fetch docs LFS files
|
||||
run: |
|
||||
git lfs install
|
||||
git lfs fetch --include="docs/**"
|
||||
|
||||
- name: Update VitePress base path
|
||||
run: |
|
||||
sed -i "s|base: '.*'|base: '$BASE_PATH'|g" docs/.vitepress/config.mts
|
||||
echo "Updated base path to: $BASE_PATH"
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6
|
||||
with:
|
||||
version: 10
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build VitePress
|
||||
run: pnpm docs:build
|
||||
|
||||
- name: Setup Aliyun CLI
|
||||
run: |
|
||||
wget https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz
|
||||
tar -xzf aliyun-cli-linux-latest-amd64.tgz
|
||||
sudo mv aliyun /usr/local/bin/
|
||||
aliyun configure set \
|
||||
--profile default \
|
||||
--mode AK \
|
||||
--access-key-id ${{ secrets.OSS_ACCESS_KEY_ID }} \
|
||||
--access-key-secret ${{ secrets.OSS_ACCESS_KEY_SECRET }} \
|
||||
--region ${{ secrets.OSS_REGION }}
|
||||
|
||||
- name: Deploy to OSS
|
||||
run: |
|
||||
OSS_PATH=oss://${{ secrets.OSS_BUCKET }}$BASE_PATH
|
||||
echo "Deploying to: $OSS_PATH"
|
||||
aliyun oss cp docs/.vitepress/dist $OSS_PATH --recursive --update
|
||||
env:
|
||||
OSS_ENDPOINT: ${{ secrets.OSS_ENDPOINT }}
|
||||
Reference in New Issue
Block a user