Skip to content

Add GitHub Actions workflow for Hexo deployment #18

Add GitHub Actions workflow for Hexo deployment

Add GitHub Actions workflow for Hexo deployment #18

Workflow file for this run

name: Deploy
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
push:
branches: [ blog ]
pull_request:
branches: [ blog ]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
name: A job to deploy blog.
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true # Checkout private submodules(themes or something else).
# Caching dependencies to speed up workflows. (GitHub will remove any cache entries that have not been accessed in over 7 days.)
- name: Cache node modules
uses: actions/cache@v3
id: cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm ci
- name: run npm
id: gererate-pages
run: |
npm install -g hexo-cli
hexo clean
hexo generate
- name: Deploy to GitHub Pages
if: success()
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: public
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# # Deploy hexo blog website.
# - name: Upload artifact
# uses: actions/upload-pages-artifact@v1
# with:
# # Upload entire repository
# path: './public'
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v1
# # echo ::set-output name=notify::"Deploy complate."
# Deploy hexo blog website.
# - name: Deploy
# id: deploy
# uses: sma11black/[email protected]
# with:
# # Github user name
# user_name: ${{ secrets.USERNAME }} # default is github-actions[bot]
# # Github email
# user_email: ${{ secrets.MAIL }} # default is 41898282+github-actions[bot]@users.noreply.github.com
# deploy_key: ${{ secrets.GITHUB_TOKEN }}
# commit_msg: ${{ github.event.head_commit.message }} # (or delete this input setting to use hexo default settings)
# # Use the output from the `deploy` step(use for test action)
# - name: Get the output
# run: |
# echo "${{ steps.deploy.outputs.notify }}"