GitHub Actions workflow for deployin' Hexo sites.
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: Build Blog | |
on: | |
# Run GH Actions if push to `master` branch | |
push: | |
branches: | |
- master # ps. change to `main` if ur default branch follow's GitHub | |
jobs: | |
deploy-blog: | |
# Use macOS Monterey 12 | |
runs-on: macos-12 # ps. change to `ubuntu-latest` if coz any problem(s) | |
steps: | |
# Get blog's src | |
- name: Get blog source file | |
uses: actions/checkout@v3 | |
# Use Node.js Version 16.x | |
- name: Use Node.js 16 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 # ps. change to `14` if coz any problem(s) | |
# Install deps via Yarn | |
- name: Install deps | |
run: | | |
npm install yarn -g | |
yarn global add hexo-cli | |
yarn install --frozen-lockfile | |
# Config system env (SSH, Git, etc.) | |
- name: Config env | |
env: | |
DEPLOY_SEC_KEY: ${{ secrets.DEPLOY_SEC_KEY }} # ps. change to your own value | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$DEPLOY_SEC_KEY" > ~/.ssh/id_rsa | |
chmod 777 ~/.ssh/id_rsa | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
git config --global user.name "Hexo Deployment" | |
git config --global user.email "khhdeployhexo@fakeaddress.nekohuan.cyou" | |
# chmod 777 may coz security problems | |
# Generate using hexo-cli | |
- name: Generate Static Files | |
run: | | |
hexo clean | |
hexo g | |
# Output to branch `static` from `master` | |
- name: Output to branch `static` | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./public | |
publish_branch: static | |
# GitHub Actions config for deployin' Hexo blog, authored by KuoHuanHuan. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment