Kubernetes 基于 ChatOps 使用 Prow 协调社区有序协作。但并不是每个团队,都愿意搭建并维护一套 Prow 机器人系统。ChatOps 实现的核心是事件驱动,这在 GitHub 中使用 Actions 也能实现。
下面是几个项目管理相关的 action
根据修改的目录添加标签
– uses: actions/labeler@main
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
在配置文件 .github/workflows/labeler.yml 中添加规则,给对 docs 目录进行修改的 Pull Requests(以下简称 PR) 自动添加 docs_label 标签:
docs_label:
– ./docs/*
根据标签添加 Issues 到 Projects
使用 srggrs/assign-one-project-github-action , 我们可以将新增的 Issues 或者 PR 添加到指定的 Projects 中。
– name: Assign NEW issues and NEW pull requests to project 2
uses: srggrs/assign-one-project-github-action@1.2.0
if: github.event.action == 'opened'
with:
project: 'https://github.com/srggrs/assign-one-project-github-action/projects/2'
也可以将包含指定标签的 Issues 或 PR 添加到指定 Project 的指定 Column 中。
– name: Assign issues and pull requests with `bug` label to project 3
uses: srggrs/assign-one-project-github-action@1.2.0
if: |
contains(github.event.issue.labels.*.name, 'bug') ||
contains(github.event.pull_request.labels.*.name, 'bug')
with:
project: 'https://github.com/srggrs/assign-one-project-github-action/projects/3'
column_name: 'Labeled'
清理长时间无人跟进的 Issues
如果一个 Issue 长达 30 天没有更新,那么下面的 workflow 将会再等 5 天,然后将其关闭。
name: 'Close stale issues and PRs'
on:
schedule:
– cron: '30 1 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
– uses: actions/stale@v3
with:
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
days-before-stale: 30
days-before-close: 5