DEMO


15.jpg

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
        yuque-hexo sync
    - name: Generate files
      run: hexo generate

    - name: Deploy blog
    	evn:
      	Github_Pages: github.com/sbwit/sbwit.github.io
        Github_Token: ${{ secrets.TOKEN_GITHUBAPI }}
      run: |
        git clone "https://${Github_Pages}" deploy_git
        mv ./deploy_git/.git ./public/
        cd ./public
        git config user.name "sbwit"
        git config user.email "17740857130@qq.com"
        git add .
        git commit -m "GitHub Actions Auto Builder at $(date +'%Y-%m-%d %H:%M:%S')"
        git push --force --quiet "https://${Github_Token}@${Github_Pages}" master:master
# -*- coding: utf8 -*-
import requests
def main_handler(event, context):
	r = requests.post("https://api.github.com/repos/sbwit/sbwit.hexo/dispatches",
	json = {"event_type": "start"},
	headers = {"User-Agent":'curl/7.52.1',
				'Content-Type': 'application/json',
				'Accept': 'application/vnd.github.everest-preview+json',
				'Authorization': 'token GITHUB_TOKEN(自己的)'})
	if r.status_code == 204:
		return "This's OK!"
	else:
		return r.status_code

官方的配置

# workflow name
name: CI Hexo

# master branch on push, auto run
on:
  push:
    branches:
      - master
jobs:
  Deploy-Pages:
    name: Deploy Hexo Public To Pages
    runs-on: ubuntu-latest

    steps:
      # check it to your workflow can access it
      # from: https://github.com/actions/checkout
      - name: Checkout Repository master branch
        uses: actions/checkout@master

      # from: https://github.com/actions/setup-node
      - name: Setup Node.js 10.x
        uses: actions/setup-node@master
        with:
          node-version: "12.14"

      - name: Setup Git Infomation
        run: |
          git config --global user.name 'sbwit' 
          git config --global user.email '17740857130@163.com'

      - name: Get Latest Commit Message
        run: |
          git log --pretty=format:"%s from Github Actions at `date +"%Y-%m-%d %H:%M:%S"`" --date=short -n 1 > commit-message.log

      - name: Setup Hexo Dependencies
        run: |
          npm install hexo-cli -g 
          npm install

      - name: Generate public files
        run: |
          hexo clean hexo generate

      - name: Deploy To Github Pages
        env:
          Github_Pages: github.com/sbwit/sbwit.github.io
          Github_Token: ${{ secrets.TOKEN_GITHUBAPI }}
        run: |
          git clone https://${Github_Pages} .github_pages 
          cd .github_pages 
          git checkout master 
          cd ../ 
          mv .github_pages/.git/ ./public/ 
          cd ./public/ 
          git add . 
          git commit -F ../commit-message.log 
          git push --force --quiet "https://${Github_Token}@${Github_Pages}" master:master

文章作者: sbwit
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 sbwit !
 上一篇
单元测试指南 单元测试指南
单元测试能帮助我们在早期就规避、发现和修复很多不易察觉的 bug 和漏洞,而且更能保障后期的需求变动和代码重构时所带来的隐患,减少测试成本和维护成本。
2021-04-13
本篇 
DEMO DEMO
这是你自定义的文章摘要内容,如果这个属性有值,文章卡片摘要就显示这段文字,否则程序会自动截取文章的部分内容作为摘要
2017-12-13
  目录