雨果自动化与Travis-ci和Github页面 [英] Hugo Automation with Travis-ci and Github pages

查看:20
本文介绍了雨果自动化与Travis-ci和Github页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GitHub托管我的博客,并使用静态站点生成器Hugo来实现这一点,但将其设置为离线并编译它,然后将公共文件夹上载到GH页面或使其在Docs文件夹中可用,这太乏味了。

所以我想自动执行该过程,以便每当我在内容中创建新的.md文件时,它都应该生成静态站点,并将公共文件夹复制到gh-Pages或以下组合-

  • "源"分支中的源文件和向母版发布的"公共"内容[适用于用户和组织页面]
  • 母版中的源文件并将"公共"文件夹内容发布到"高页"
  • 您要提出的任何其他方法

注意:我主要想使用Travis-ci,但任何其他自动化平台也会很酷

CICD

现在(2020年10月),您不需要使用外部推荐答案服务(如TRAVIS-CI)。

Michelle Mannering中的";GitHub Action Hero · James Ives and "GitHub Pages Deploy" ";所述,您可以使用GitHub操作。

具体而言,James IvesGitHub Pages Deploy Action

此GitHub操作将自动将您的项目部署到GitHub页面。
它可以配置为将生产就绪代码推送到您想要的任何分支中,包括gh-pagesdocs
它还可以处理跨存储库部署。

示例:

name: Build and Deploy
on: [push]
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout 🛎️
        uses: actions/checkout@v2.3.1 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
        with:
          persist-credentials: false

      - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
        run: |
          npm install
          npm run build

      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@3.6.2
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: gh-pages # The branch the action should deploy to.
          FOLDER: build # The folder the action should deploy.
          CLEAN: true # Automatically remove deleted files from the deploy branch

这篇关于雨果自动化与Travis-ci和Github页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆