Write blog posts through Issues and automatically deploy to GH-Page.

introduce

  • acyortEngine core, which manages plug-ins, workflows, andhtmlOutput, etc.
  • acyort-donob-pluginsIs:acyortPlugin for pullingissuesAfter processing, the corresponding template will be rendered.

The overall steps

  • Create a new repO on Github
  • Write configuration file
  • addgithub token, permissions forrepo::public_repo
  • incircleCiAdd the correspondingrepoAnd createcircleci token(Need to be saved)
  • incircleciThe corresponding project is added tovariable.
  • inrepoaddwebhook
  • writeissues

About gh – pages

Gh-pages are available in two forms, please refer to the official instructions for details:

  • The project named username.github. IO is the User page assigned to each user.

  • The other is the Prject Page, the GH-Pages generated in each project through the GH-Pages branch or through the Docs folder.

No matter, in what way to establish gh-Pages can be.

However, if the repO is created as username.github. IO, the content can only be stored in the Master branch and cannot be generated in the GH-Pages or docs folder like other repOs.

Github. IO to create gh-pages

The detailed steps

Create a repo

  • To create ausername.github.iotherepoIs responsible for receiving generatedhtmlContent, and generateuser page.
  • To create ablog-config(name optional), for managementblogConfiguration, andissuesManagement.

Apply for two tokens

Both tokens must be saved by themselves. If you close them, they will not be recovered.

  • github token

    Apply for a Github token with write permission. Scope selects repo::public_repo, which is used to push generated files directly into the project through the API.

  • circleci token

    Apply for a Circleci token to trigger a Circle build via webhook.

Write configuration file

In blog-config, create the following files:

| - circleci | - config. Yml / / circleci configuration file | - config. Yml / / acyort configuration file | - package. Json / / the needless to sayCopy the code
  • package.json

    {
      "name": "blog name"."version": "1.0.0"."description": "blog"."main": "index.js"."scripts": {
        "deploy": "acyort flow"
      },
      "dependencies": {
        "acyort": "^ 3.1.1." "."acyort-donob-renderer": "^ 1.5.0." "."acyort-plugin-fetch-issues": "^ 1.3.1." "."acyort-plugin-rss": "^ 1.5.0." "."acyort-templates-donob-plus": "^ 1.5.1." "."gh-pages": "^ 2.0.1." "}}Copy the code
  • Config.yml (Acyort configuration file)

    title: blog name # Blog name
    description: blog desc # Blog Profile
    url: http://username.github.io # blog url
    template: acyort-templates-donob-plus
    menu:
      Archives: /archives/
      Tags: /tags/
    repository: username/blog-config # Write projects for issues
    public: public
    timezone: Asia/Shanghai
    plugins:
      - acyort-plugin-fetch-issues
      - acyort-donob-renderer
    Copy the code
  • .circleci/config.yml

    # Notice that this file is called config.yml and is in the.circleci directory
    version: 2
    jobs:
      build:
        docker:
          - image: node:latest
        working_directory: ~/acyort
        branches:
          only:
            - master
        steps:
          - checkout
          - restore_cache:
              keys:
                - yarn-packages-{{ checksum "yarn.lock" }}
          - run: yarn install
          - save_cache:
              name: Save Yarn Package Cache
              key: yarn-packages-{{ checksum "yarn.lock" }}
              paths:
                - ~/.cache/yarn
          - run: yarn deploy
          - run: git config user.name "" # your github username
          - run: git config user.email "" # Your Github email
          - run: npx gh-pages -d public -r https://${gh_token}@github.com/username/username.github.io.git -b master -m "Updated by circleci - `date`" # ${gh_token}, which is a Github token with write permission, will be configured in circleci.
    Copy the code

Configuration circleci

  • willblog-configProject joincircleciIn the.
  • chooselinuxandnodeThe environment.
  • pointstart build, should befailBecause thegh_tokenIt has not been added to the environment variable.
  • Click on the left-hand columnJobTo findblog-configProject, click Settings
  • inBUILD SETTINGSFound in theEnvironment Variables
  • Click on theAdd variable
  • nameforgh_token(The name should followconfig.ymlIn the${gh_token}),valueFill in the one you just applied forgh-token.
  • Go back tocircleciIn the project, click on the last onebuild failEntry, in the upper right cornerrebuild
  • Barring accidents, we should succeed nowbuildAnd,username.github.ioThis repository also has corresponding files.

Configuration webhook

Go back to the blog-config project to configure

  • pointsettings
  • pointwebhook
  • pointAdd webhook
  • Payload URLFill in the ‘https://circleci.com/api/v1.1/project/github/:username/:project/tree/:branch?circle-token=:token’ (to replace the corresponding field), one of them:tokenfromcircleciThe application oftoken)
  • Content-Typechooseapplication/json
  • The following optionlet me select xxxAnd check theissuesoptions
  • Click on the bottomsave
  • complete

Write free

At this point, the blog has been set up, just need to write issues in blog-config, and it will be synchronously deployed to GH-Pages.

The last

For more configurations, see

  • acyort
  • acyort-donob-plugins
  • blog-config