Skip to content

Build & Deploy & Sync Gitee & Send Email #888

Build & Deploy & Sync Gitee & Send Email

Build & Deploy & Sync Gitee & Send Email #888

Workflow file for this run

name: Build & Deploy & Sync Gitee & Send Email
on:
# push:
# branches:
# - main
# paths-ignore: # 下列文件的变更不触发部署
# - LICENSE
# - README.md
schedule:
- cron: '55 3,15 * * *' # 大概每天北京时间 12:00 和 00:00 触发(任务可能需要排队,有延迟)
env:
TZ: Asia/Shanghai # 设置时区:中国上海
QQ_EMAIL: ${{ secrets.QQ_EMAIL }} # 用于发送邮件
WY_EMAIL: ${{ secrets.WY_EMAIL }}
QQ_EMAIL_AUTH: ${{ secrets.QQ_EMAIL_AUTH }}
ACCESS_TOKEN: ${{ secrets.DEPLOY_TOKEN }} # 用于部署到 Github Pages,取 Github 数据
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Set the timezone
run: |
sudo timedatectl set-timezone "$TZ"
echo "当前时区: $TZ"
echo "当前时间: $(date +"%Y-%m-%d %H:%M:%S")"
echo "CURRENT_TIME=$(date +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV
- name: Set USERNAME and REPO_NAME
run: |
echo "USERNAME=${{ github.actor }}" >> $GITHUB_ENV
echo "REPO_NAME=${{ github.repository }}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: latest
run_install: true
- name: Install ni
run: pnpm i -g @antfu/ni
- name: Install deps
run: nci
- name: Update Github Data
run: |
nr update:data
git status
- name: Generate
run: |
nr generate
- name: Deploy to github-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.DEPLOY_TOKEN }}
publish_dir: ./.output/public
user_name: github-actions[bot]
user_email: github-actions[bot]@users.noreply.github.com
# - name: Sync to Gitee
# uses: wearerequired/git-mirror-action@master
# env:
# # 注意在 Settings->Secrets 配置 GITEE_RSA_PRIVATE_KEY
# SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
# with:
# # 注意替换为你的 GitHub 源仓库地址
# source-repo: git@github.com:${{ env.REPO_NAME }}.git
# # 注意替换为你的 Gitee 目标仓库地址
# destination-repo: git@gitee.com:${{ env.REPO_NAME }}.git
# - name: Build Gitee Pages
# uses: yanglbme/gitee-pages-action@main
# with:
# # 注意替换为你的 Gitee 用户名
# gitee-username: ${{ env.USERNAME }}
# # 注意在 Settings->Secrets 配置 GITEE_PSWD
# gitee-password: ${{ secrets.GITEE_PSWD }}
# # 注意替换为你的 Gitee 仓库,仓库名严格区分大小写,请准确填写,否则会出错
# gitee-repo: ${{ env.REPO_NAME }}
# # 要部署的分支,默认是 master,若是其他分支,则需要指定(指定的分支必须存在)
# branch: gh-pages
# - name: Send Email
# run: |
# nr send