deploy #215
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy To Github Pages | |
on: | |
# 允许手动push触发 | |
push: | |
branches: | |
- master | |
# 允许外部仓库事件触发 | |
repository_dispatch: | |
types: | |
- deploy | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 检查分支 | |
uses: actions/checkout@master | |
- name: 安装node环境 | |
uses: actions/setup-node@master | |
with: | |
node-version: "16.x" | |
- name: 安装pnpm | |
run: | | |
export TZ='Asia/Shanghai' | |
npm install [email protected] -g | |
- name: 安装依赖 | |
run: | | |
export TZ='Asia/Shanghai' | |
pnpm install --prod | |
- name: 清除缓存 | |
env: | |
CLEAN_CACHE: ${{ secrets.CLEAN_CACHE }} | |
if: ${{ env.CLEAN_CACHE == 'true' }} | |
run: | | |
pnpm clean:yuque-token | |
pnpm clean:yuque-pwd | |
pnpm clean:notion | |
pnpm clean:flowus | |
- name: 拉取语雀&Notion&FlowUs的文章 | |
env: | |
YUQUE_TOKEN: ${{ secrets.YUQUE_TOKEN }} | |
YUQUE_USERNAME: ${{ secrets.YUQUE_USERNAME }} | |
YUQUE_PWD: ${{ secrets.YUQUE_PWD }} | |
YUQUE_LOGIN: ${{ secrets.YUQUE_LOGIN }} | |
YUQUE_REPO: ${{ secrets.YUQUE_REPO }} | |
NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} | |
NOTION_DATABASE_ID: ${{ secrets.NOTION_DATABASE_ID }} | |
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }} | |
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }} | |
COS_IMAGE_BUCKET: ${{ secrets.COS_IMAGE_BUCKET }} | |
COS_IMAGE_REGION: ${{ secrets.COS_IMAGE_REGION }} | |
FLOWUS_TABLE_PAGE_ID: ${{ secrets.FLOWUS_TABLE_PAGE_ID }} | |
WORDPRESS_USERNAME: ${{ secrets.WORDPRESS_USERNAME }} | |
WORDPRESS_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }} | |
WORDPRESS_ENDPOINT: ${{ secrets.WORDPRESS_ENDPOINT }} | |
FEISHU_APP_ID: ${{ secrets.FEISHU_APP_ID }} | |
FEISHU_APP_SECRET: ${{ secrets.FEISHU_APP_SECRET }} | |
FEISHU_FOLDER_TOKEN: ${{ secrets.FEISHU_FOLDER_TOKEN }} | |
run: | | |
pnpm sync:flowus | |
pnpm sync:yuque-token | |
pnpm sync:notion | |
pnpm sync:wordpress | |
pnpm sync:feishu | |
# 在非国内CI/CD环境中使用语雀(账号密码)方式,例如Github Workflow | |
# 会导致语雀后台登录设备中出现大量美国IP, | |
# 目前尚不清楚语雀是否会有安全限制措施,请谨慎使用。 | |
# 推荐本地同步时使用。 | |
# pnpm sync:yuque-pwd | |
- name: 配置Git用户名邮箱 | |
run: | | |
git config --global user.name "1874" | |
git config --global user.email "[email protected]" | |
- name: 提交yuque拉取的文章到GitHub仓库 | |
run: | | |
echo `date +"%Y-%m-%d %H:%M:%S"` begin > time.txt | |
git add . | |
git commit -m "Refresh elog.cache.json" -a | |
- name: 推送文章到仓库 | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: 生成静态文件 | |
env: | |
YUQUE_TOKEN: ${{ secrets.YUQUE_TOKEN }} | |
run: | | |
pnpm docs:build | |
- name: 部署到Github Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
deploy_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
publish_dir: docs/.vitepress/dist | |
external_repository: LetTTGACO/LetTTGACO.github.io | |
publish_branch: master | |
commit_message: ${{ github.event.head_commit.message }} |