Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

品尝 CI/CD 带来的爽感 #13

Open
RedCrazyGhost opened this issue Aug 4, 2023 · 0 comments
Open

品尝 CI/CD 带来的爽感 #13

RedCrazyGhost opened this issue Aug 4, 2023 · 0 comments
Labels
Docker fa-brands fa-docker Git fa-brands fa-git-alt Github fa-brands fa-github Linux fa-brands fa-linux Ubuntu fa-brands fa-ubuntu

Comments

@RedCrazyGhost
Copy link
Owner

背景

🤔️想让Issue和Readme.md内容自动同步,一次修改处处更改,整合进入流程

技术选择

  • Github仓库使用Github Action作为CI/CD的工具
  • 个人编写Python调用Github API进行自动处理 (干不动了,累了)

Github Action

优点:

  • 文档内容丰富:GitHub Actions 快速入门GitHub GraphQL API 文档
  • 社区内容丰富:有大佬编写好的Github Action包可以直接使用
  • 编写内容较少:采用yml文件方式编写任务流程
  • 可视化界面:方便定位问题
  • 通知:依托Github服务器可收到执行失败通知
# Github Action Name
name: 'Auto Issues'

# 环境配置
env:
  # 设置时区 
  TZ: Asia/Shanghai

# 触发条件
on: issues

# 执行任务列表
jobs:
  # Job名称
  IssusToReadme:
    # Docker 运行环境
    runs-on: ubuntu-latest
    # 任务超时时间
    timeout-minutes: 10
    # 判断操作的 issue number 为 1 则继续执行
    if: github.event.issue.number == 1
    # 执行步骤
    steps:

    # 控制台打印issue标题和内容
    - name: watch issue context
      run: |
        echo "Issue title: ${{ github.event.issue.title }}"
        echo "Issue body: ${{ github.event.issue.body }}"

    # 拉取仓库中readme.md文件
    - name: pull readme.md file
      uses: actions/checkout@v3
      with:
        sparse-checkout: |
          readme.md
        sparse-checkout-cone-mode: false

    # 将issue内容覆盖readme.md文件
    - name: write readme.md file
      run: echo "${{ github.event.issue.body }}" > readme.md

    # 将需改后的readme.md文件提交到仓库
    - name: push readme.md file
      run: |
        git config user.name [bot]github-actions
        git config user.email github-actions@github.com
        git add .
        git commit -m "[bot]github action issues update readme.md"
        git push
@RedCrazyGhost RedCrazyGhost added Github fa-brands fa-github Git fa-brands fa-git-alt Ubuntu fa-brands fa-ubuntu Docker fa-brands fa-docker Linux fa-brands fa-linux labels Aug 4, 2023
@RedCrazyGhost RedCrazyGhost changed the title Blog引入CI/CD 品尝 CI/CD 带来的爽感 Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docker fa-brands fa-docker Git fa-brands fa-git-alt Github fa-brands fa-github Linux fa-brands fa-linux Ubuntu fa-brands fa-ubuntu
Projects
None yet
Development

No branches or pull requests

1 participant