deploy.yml #8
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: 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 |