Skip to content

deploy.yml

deploy.yml #8

Workflow file for this run

name: Deploy Hexo to GitHub Pages
on:
push:
branches:
- gh-pages
env:
GIT_USER: fengjiansu
GIT_EMAIL: [email protected]
DEPLOY_REPO: fengjiansu/fengjiansu.github.io
DEPLOY_BRANCH: gh-pages
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout deploy repo
uses: actions/checkout@v4
with:
repository: ${{ env.DEPLOY_REPO }}
ref: ${{ env.DEPLOY_BRANCH }}
path: .deploy_git
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '14'
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install Dependencies
run: npm install
- name: Setup Git
run: |
git config --global user.name 'fengjiansu'
git config --global user.email '[email protected]'
- name: Deploy Hexo
env:
HEXO_DEPLOY_PRI: ${{secrets.HEXO_DEPLOY_PRI}}
run:
sudo timedatectl set-timezone "Asia/Shanghai"
mkdir -p ~/.ssh
echo "$HEXO_DEPLOY_PRI" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
npx hexo clean
npx hexo generate
npx hexo deploy