Add files via upload #35
Workflow file for this run
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-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# 获取博客源码和主题 | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: 'true' | |
# 这里用的是 Node.js 13.x,14.x 生成 Hexo 静态页面会有问题 | |
- name: Set up Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: '20' | |
# 安装依赖 | |
- name: Install Dependencies | |
run: | | |
npm install | |
# 从之前设置的 secret 获取部署私钥 | |
- name: Setup SSH Keys and known_hosts | |
env: | |
HEXO_DEPLOY_PRI: ${{ secrets.HEXO_DEPLOY_PRI }} | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$HEXO_DEPLOY_PRI" > ~/.ssh/id_rsa | |
chmod 700 ~/.ssh | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
git config --global user.email "[email protected]" | |
git config --global user.name "ExquisiteCore" | |
npm install hexo-cli -g | |
npm install | |
# 生成并部署 `npx hexo clean && npx hexo g -d` or `npm run deploy` | |
- name: Deploy | |
run: | | |
hexo clean | |
hexo deploy |