Skip to content

fix(ci): use latest nodejs #330

fix(ci): use latest nodejs

fix(ci): use latest nodejs #330

Workflow file for this run

name: Build Demo Site
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
# Setup Node.js env
- uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
# Get Hexo test utils
- uses: actions/checkout@v4
with:
repository: 'hexojs/hexo-theme-unit-test'
# Make dirs for themes
- name: Make dirs for themes
run: mkdir themes
# Clone Kratos-Rebirth into themes dir
- uses: actions/checkout@v4
with:
path: 'themes/kratos-rebirth'
# Clone Demo site configurations & assets into tmp
- uses: actions/checkout@v4
with:
repository: 'kratos-rebirth/demo-site-v3'
path: '/tmp/demo-site'
# Build fresh theme files
- name: Build theme files
run: |
cd ./themes/kratos-rebirth
pnpm install --frozen-lockfile
pnpm build
# Edit hexo site settings
- name: Edit Hexo site settings
run: |
sed -i "s/title: Hexo/title: 'Kratos : Rebirth'/" "_config.yml"
sed -i "s/subtitle: ''/subtitle: 一个可爱而现代的 Hexo 主题/" "_config.yml"
sed -i "s/description: ''/description: 欢迎使用这个主题,希望能给您带来美好的体验。/" "_config.yml"
sed -i "s/author: John Doe/author: Candinya/" "_config.yml"
sed -i "s/language:/language: zh-CN/" "_config.yml"
sed -i "s|url: http://example.com|url: https://demo.krt.moe|" "_config.yml"
sed -i "s|permalink: :year/:month/:day/:title/|permalink: posts/:title/|" "_config.yml"
sed -i "s/theme: landscape/theme: kratos-rebirth/" "_config.yml"
# Copy extended theme settings
- name: Copy extended theme settings
run: mv "/tmp/demo-site/_config.kratos-rebirth.yml" "_config.kratos-rebirth.yml"
# Prepare assets
- name: Prepare assets
run: mv /tmp/demo-site/assets source/demo-assets
# Edit theme settings
- name: Edit theme settings
run: |
sed -i "s|clientID: 'GitHub Application Client ID'|clientID: ${{ secrets.GH_OAUTH_ID }}|" "_config.kratos-rebirth.yml"
sed -i "s|clientSecret: 'GitHub Application Client Secret'|clientSecret: ${{ secrets.GH_OAUTH_SECRET }}|" "_config.kratos-rebirth.yml"
# Install Hexo env
- name: Install Hexo environment
run: npm install
# Install post-time-fix plugin
- name: Install post-time-fix plugin
run: npm install hexo-filter-date-from-git --save
# Hexo build demo site
- name: Hexo build demo site
run: npx hexo generate --force
- name: Upload artifacts for pages
uses: actions/upload-pages-artifact@v3
with:
path: public
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4