# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Stable Theme Test

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

env:
  TZ: Asia/Shanghai

jobs:
  theme_test:
    name: Hexo build & deploy
    runs-on: ubuntu-latest

    steps:
    - name: Checkout codes
      uses: actions/checkout@v2
      with:
        repository: 'blleng/lx-test'

    - name: Setup node
      uses: actions/setup-node@v1
      with:
        node-version: '16.x'

    - name: Cache node modules
      uses: actions/cache@v1
      with:
        path: ~/.npm
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

    - name: Install dependencies
      run: |
        npm install -g hexo-cli
        npm install
        git clone -b dev https://github.com/blleng/hexo-theme-lx/ themes/lx
    - name: Generate files
      run: |
        hexo clean
        hexo generate
    - name: Deploy to gh-page🚀
      uses: JamesIves/github-pages-deploy-action@4.1.4
      with:
        git-config-name: blleng
        git-config-email: l0bl@outlook.com
        repository-name: blleng/lx-test
        branch: gh-page
        token: ${{ secrets.LX_STABLE_REPO }}
        folder: public