Skip to content

Commit

Permalink
ci: conditionally sync static files to server based on FTP key presence
Browse files Browse the repository at this point in the history
  • Loading branch information
rockbenben committed Jan 13, 2024
1 parent f41c12b commit de0fea8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ on:
jobs:
LearnData-build:
runs-on: ubuntu-latest
env:
FTP_HOST: ${{ secrets.ftp_host }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
# 获取所有标记和分支的所有历史记录(updatetime 必须,否则每次都会变化)
fetch-depth: 0
# 如果你文档需要 Git 子模块,取消注释下一行
# 如果文档包含 Git 子模块,请取消注释下一行
# submodules: true

- name: Install pnpm
Expand All @@ -29,7 +31,7 @@ jobs:
node-version: 20
cache: pnpm

# 将读书笔记复制到静态页路径,然后构建页面
# 复制读书笔记到静态页面路径,并构建页面
- name: Build Docs
env:
NODE_OPTIONS: --max_old_space_size=8192
Expand All @@ -41,13 +43,13 @@ jobs:
- name: Deploy GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
# 这是文档部署到的分支名称
# 指定静态文件部署到的分支
branch: gh-pages
folder: docs/.vuepress/dist

### 没有服务器的话,请删除本区块代码,防止报错 ###
# 将页面推送到服务器,timeout 时间从默认的 1 分钟调整到 10 分钟。
# 如果配置了 FTP 服务器密钥,才会执行本步骤,将页面静态文件同步到服务器
- name: 📂 Sync files
if: env.FTP_HOST != ''
uses: SamKirkland/[email protected]
with:
local-dir: docs/.vuepress/dist/
Expand All @@ -56,4 +58,3 @@ jobs:
password: ${{ secrets.ftp_password }}
port: ${{ secrets.ftp_port }} # 建议更改默认的 21 端口
timeout: 600000
### 没有服务器的话,请删除本区块代码,防止报错 ###

0 comments on commit de0fea8

Please sign in to comment.