vault backup: 2024-09-03 14:51:18 #233
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: Pages | |
# 触发器、分支 | |
on: | |
push: | |
branches: | |
- hexo # default branch | |
jobs: | |
# 子任务 | |
pages: | |
runs-on: ubuntu-latest # 定运行所需要的虚拟机环境 | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v2 | |
with: | |
ref: hexo | |
# submodules: true | |
# fetch-depth: 0 | |
- name: Use Node.js 19.x | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '19.3.0' # 自己正在使用的node版本即可 | |
- name: Install hexo | |
run: | | |
export TZ='Asia/Shanghai' | |
npm install hexo-cli -g | |
- name: 缓存 Hexo | |
uses: actions/cache@v1 | |
id: cache | |
with: | |
path: node_modules | |
key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}} | |
- name: 安装依赖 | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
npm install --save | |
npm install hexo-uuid --save | |
- name: 生成静态文件 | |
run: | | |
hexo clean | |
hexo g | |
# - name: 更新 hexo 分支 #此处master:master 指从本地的master分支提交到远程仓库的master分支(不是博客的分支写master即可),若远程仓库没有对应分支则新建一个。如有其他需要,可以根据自己的需求更改。 | |
# run: | | |
# git config --global user.name '${{ secrets.GITHUBUSERNAME }}' | |
# git config --global user.email '${{ secrets.GITHUBEMAIL }}' | |
# git branch --show-current | |
# git add . | |
# git commit -m "${{ github.event.head_commit.message }} $(date +"%Z %Y-%m-%d %A %H:%M:%S") Updated By Github Actions hexo" | |
# git push "https://${{ secrets.GITHUBUSERNAME }}:${{ secrets.GITHUBTOKEN }}@github.com/${{ secrets.GITHUBUSERNAME }}/${{ secrets.GITHUBUSERNAME }}.github.io.git" hexo:hexo | |
- name: 部署 #此处master:master 指从本地的master分支提交到远程仓库的master分支(不是博客的分支写master即可),若远程仓库没有对应分支则新建一个。如有其他需要,可以根据自己的需求更改。 | |
run: | | |
cd ./public | |
git init | |
git config --global user.name '${{ secrets.GITHUBUSERNAME }}' | |
git config --global user.email '${{ secrets.GITHUBEMAIL }}' | |
git add . | |
git commit -m "${{ github.event.head_commit.message }} $(date +"%Z %Y-%m-%d %A %H:%M:%S") Updated By Github Actions" | |
git push --force --quiet "https://${{ secrets.GITHUBUSERNAME }}:${{ secrets.GITHUBTOKEN }}@github.com/${{ secrets.GITHUBUSERNAME }}/${{ secrets.GITHUBUSERNAME }}.github.io.git" master:master |