site update #116
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: RXZ2GC | |
# 触发条件:在 push 到 hexo-blog-backup 分支后触发 | |
on: | |
push: | |
branches: | |
- source | |
env: | |
TZ: Asia/Shanghai | |
jobs: | |
build: | |
runs-on: ubuntu-latest # 使用最新的 Ubuntu 系统作为编译部署的环境 | |
steps: | |
- name: Checkout codes | |
uses: actions/checkout@v4 | |
- name: Setup node | |
# 设置 node.js 环境 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: Get Latest Commit Message | |
run: | | |
git log --pretty=format:"%s from Github Actions at `date +"%Y-%m-%d %H:%M:%S"`" --date=short -n 1 > commit-message.log | |
- name: Cache node modules | |
# 设置包缓存目录,避免每次下载 | |
uses: actions/cache@v3 | |
id: cache-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
- name: Install hexo | |
# 下载 hexo-cli 脚手架及相关安装包 | |
run: | | |
npm install hexo-cli -g --no-audit | |
npm install --no-audit | |
- name: Install dependencies | |
# 下载 hexo-cli 脚手架及相关安装包 | |
if: steps.cache-modules.outputs.cache-hit != 'true' | |
run: | # **如果仓库里没有 package-lock.json,上传一下,npm ci 必须要有 package-lock.json** | |
npm ci | |
- name: Generate public files # 生成 | |
run: | | |
hexo clean | |
hexo generate | |
- name: Deploy 2 github | |
env: | |
Github_Pages: github.com/budaig/budaig.github.com.git | |
Github_Token: ${{ secrets.token_GitAPI }} | |
# 将编译后的博客文件推送到指定仓库 | |
run: | | |
git config --global user.name "budaig" | |
git config --global user.email "[email protected]" | |
git clone https://${Github_Pages} .github_pages | |
cd .github_pages | |
git checkout -b master | |
cd ../ | |
mv .github_pages/.git/ ./public/ | |
cd ./public/ | |
git add . | |
git commit -F ../commit-message.log | |
git push --force --quiet "https://${Github_Token}@${Github_Pages}" master:master | |
- name: Deploy 2 Coding | |
env: | |
Coding_Pages: e.coding.net/budaim/budaim.git | |
Coding_Token: ${{ secrets.token_CodinAPI }} | |
Coding_Username: ${{ secrets.User_Codin }} | |
# 将编译后的博客文件推送到指定仓库 | |
run: | | |
git config --global user.name "budaim" | |
git config --global user.email "[email protected]" | |
git clone https://${Coding_Username}:${Coding_Token}@${Coding_Pages} .coding_pages | |
cd .coding_pages | |
git checkout -b master | |
#git checkout -b coding-pages | |
cd ../ | |
rm -r ./public/.git/ | |
mv .coding_pages/.git/ ./public/ | |
cd ./public/ | |
git add . | |
git commit -F ../commit-message.log | |
git push --force --quiet "https://${Coding_Username}:${Coding_Token}@${Coding_Pages}" master:master | |
# git push --force --quiet "https://${Coding_Username}:${Coding_Token}@${Coding_Pages}" coding-pages:coding-pages | |