Giter Club home page Giter Club logo

Comments (6)

Raydon10 avatar Raydon10 commented on June 16, 2024

我在使用github actions将github private仓库的代码自动部署到github pages上,但这过程中发现个问题,无法写入更新时间到private仓库的lastGeneratePath.log里,请问是否有好的办法,github actions代码如下:

name: Blog CI/CD

on: [push, repository_dispatch]

jobs:
  blog-cicd:
    name: Hexo blog build & deploy
    runs-on: ubuntu-latest
    env:
      TZ: Asia/Shanghai
    steps:
    - name: Checkout codes
      uses: actions/checkout@v2

    - name: Setup node
      uses: actions/setup-node@v1
      with:
        node-version: '12.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 hexo-cli -g
        npm install yuque-hexo -g
        npm install
        npm run yuque
        
    - name: Generate files
      run: hexo generate
      
    - name: Deploy blog
      run: |
        git clone "https://${{ secrets.GH_REF }}" deploy_git
        mv ./deploy_git/.git ./public
        cd ./public
        git config user.name "xxx"
        git config user.email "xxx"
        git add .
        git commit -m "GitHub Actions Auto Builder at $(date +'%Y-%m-%d %H:%M:%S')"
        git push --force --quiet "https://${{ secrets.GH_TOKEN }}@${{ secrets.GH_REF }}" main:main

from yuque-hexo.

LetTTGACO avatar LetTTGACO commented on June 16, 2024

看不出来问题在哪,但是部署到githubpages有插件的,可以试一下以下流程
仓库分为博客源码仓库和GithubPages仓库

  1. 配置配置Git用户名邮箱
  2. yuque-hexo sync
  3. 上传代码到博客源码仓库
  4. hexo generate 生成静态文件
  5. 利用peaceiris/actions-gh-pages@v3 上传文章到GitHub Pages
      - name: 上传文章到GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.SSH_PRIVATE_KEY }}
          external_repository: LetTTGACO/LetTTGACO.github.io // 你的GH地址
          publish_branch: master
          publish_dir: ./public
          commit_message: ${{ github.event.head_commit.message }} // 默认

from yuque-hexo.

LetTTGACO avatar LetTTGACO commented on June 16, 2024

至于第三步 推送代码到博客源码仓库。我也使用的插件

      - name: 推送文章到仓库
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

from yuque-hexo.

LetTTGACO avatar LetTTGACO commented on June 16, 2024

参考我的部署配置

name: Deplo

on:
  # 允许手动push触发
  push:
    branches:
      - master
  # 允许外部仓库事件触发
  repository_dispatch:
    types:
      - start

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: 检查分支
        uses: actions/checkout@master

      - name: 安装node环境
        uses: actions/setup-node@master
        with:
          node-version: "12.x"

      - name: 缓存依赖
        uses: actions/cache@v1
        id: cache
        with:
          path: node_modules
          key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}}

      - name: 安装依赖
        if: steps.cache.outputs.cache-hit != 'true'
        run: |
          export TZ='Asia/Shanghai'
          npm install

      - name: 拉取语雀的文章
        env:
          YUQUE_TOKEN: ${{ secrets.YUQUE_TOKEN }}
        run: |
          npm run yuque:sync      //  yuque-hexo sync

      - name: 配置Git用户名邮箱
        run: |
          git config --global user.name "1874"
          git config --global user.email "[email protected]"

      - name: 提交yuque拉取的文章到GitHub源码仓库
        run: |
          echo `date +"%Y-%m-%d %H:%M:%S"` begin > time.txt
          git add .
          git commit -m "Refresh yuque json" -a

      - name: 推送文章到仓库
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

      - name: 生成静态文件
        run: |
          npm run hexo:clean       // hexo clean
          npm run hexo:build      // hexo generate

      - name: 上传文章到GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.SSH_PRIVATE_KEY }}
          external_repository: LetTTGACO/LetTTGACO.github.io
          publish_branch: master
          publish_dir: ./public
          commit_message: ${{ github.event.head_commit.message }}

from yuque-hexo.

Raydon10 avatar Raydon10 commented on June 16, 2024

我的意思是,每次从博客源码仓库用github actions部署到github pages仓库,actions里每次都必须拉取语雀所有文章,然后再重新生成到github pages吗?因为lastGeneratePath.log无法起作用...

from yuque-hexo.

LetTTGACO avatar LetTTGACO commented on June 16, 2024

我的意思是,每次从博客源码仓库用github actions部署到github pages仓库,actions里每次都必须拉取语雀所有文章,然后再重新生成到github pages吗?因为lastGeneratePath.log无法起作用...

不会啊,我的就是这么配置的,能正常提交的,lastGeneratePath.log写入我倒是没遇到过,可以看下日志。

from yuque-hexo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.