Skip to content

Deploy 1000h website(aliyun) #65

Deploy 1000h website(aliyun)

Deploy 1000h website(aliyun) #65

name: Deploy 1000h website(aliyun)
env:
OSS_ENDPOINT: oss-cn-beijing.aliyuncs.com
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "1000-hours/**"
pull_request:
branches:
- main
paths:
- "1000-hours/**"
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
# checkout the code
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Setup node env
uses: actions/setup-node@master
with:
node-version: "20"
- name: Install dependencies
run: yarn install
- name: Write Aliyun OSS Config
run: |
cat <<EOF > 1000-hours/.vitepress/config.aliyun.js
// Aliyun OSS 配置
export default {
base: "/1000-hours/",
transformHtml: (code, id, html) => {
// 使用正则匹配 <span data-audio-*> 并替换路径
return html.content.replace(/(<span[^>]*\s)data-audio-([\w-]+)="\/audios\/(.*?)"/g, (match, before, key, value) => {
return \`\${before}data-audio-\${key}="/1000-hours/audios/\${value}"\`
})
}
}
EOF
- name: Build
run: yarn docs:build
- uses: manyuanrong/[email protected]
with:
endpoint: ${{ env.OSS_ENDPOINT }}
access-key-id: ${{ secrets.GLOBAL_OSS_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.GLOBAL_OSS_ACCESS_KEY_SECRET }}
- run: ossutil cp -r -u -f 1000-hours/.vitepress/dist ${{ secrets.ALIYUN_OSS_PRESS_URL }}/1000-hours/ --include "*" -e ${{ env.OSS_ENDPOINT }}
- run: ossutil set-meta ${{ secrets.ALIYUN_OSS_PRESS_URL }}/1000-hours/ Cache-Control:no-cache --include "*.html" -r -f --update -e ${{ env.OSS_ENDPOINT }}