增加 AriaNg #40
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: Hexo Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-blog: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 克隆仓库 | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: 安装Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: 安装Python, 并缓存包 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: 预处理 markdown 文件 | |
run: | | |
python3 main.py prod | |
- name: 设置包缓存目录,避免每次下载 | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
- name: 查看目录结构 | |
run: | | |
sudo apt install tree | |
sudo tree . | |
- name: 下载 hexo-cli 脚手架及相关安装包 | |
run: | | |
npm install -g hexo-cli | |
npm install | |
- name: 编译 markdown 文件 | |
run: | | |
hexo clean | |
hexo generate | |
- name: 处理编译后的文件 | |
run: | | |
echo "# Cloudflare Page" > ./public/README.md | |
- name: 将编译后的博客文件推送到指定仓库 | |
env: | |
GITHUB_REPO: github.com/YangRucheng/Blog-Hexo | |
run: | | |
cd ./public && git init && git add . | |
git branch -m pages | |
git config user.name "YangRucheng" | |
git config user.email "[email protected]" | |
git add . | |
git commit -m "GitHub Actions Auto Builder at $(date +'%Y-%m-%d %H:%M:%S')" | |
git push --force --quiet "https://${{ secrets.ACCESS_TOKEN }}@$GITHUB_REPO" pages:pages | |