

利用GitHub Actions自动将项目贡献者列表添加到README中
source link: https://wiki.eryajf.net/pages/2cb154/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

利用GitHub Actions自动将项目贡献者列表添加到README中原创
当我们负责的项目有越来越多的人加入进行协作之后,将贡献者添加到 README 中是一个很好的激励作用,很多大的项目也都是这么做的,本文就来讲一下,如何借助 Github Actions 自动将项目贡献者列表添加到 README 中。
所用 Actions: contributors-readme-action (opens new window)
使用配置其实非常简单,基本上阅读完官方介绍文档就可以上手使用了,这里说一两个需要注意的地方。
首先需要在将要生成目录的文件内,指定目录生成位置,通常是 README.md
,在要生成的地方添加如下内容:
## 贡献者
<!-- readme: collaborators,contributors -start -->
<!-- readme: collaborators,contributors -end -->
然后添加 Actions 配置文件,e.g. .github/workflows/reademe-contributors.yml
:
on:
push:
branches:
- main
name: Generate a list of contributors
jobs:
contrib-readme-en-job:
runs-on: ubuntu-latest
name: A job to automate contrib in readme
steps:
- name: Contribute List
uses: akhilmhdh/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.CONTRIBUTORS_TOKEN }}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
配置文件中用到了 GITHUB_TOKEN,我的这篇文章有详细介绍如何生成以及配置,可直接参考: https://wiki.eryajf.net/pages/47a507/ (opens new window)
接下来就是当 main 分支 push 代码之后,就会自动生成贡献者列表到 readme 中了。我这边测试项目生成效果如下:

当然,如果觉得如上配置比较麻烦,可以直接采用如下方式,会更加简单一些,直接添加如下内容到README就会自动生成:
## 贡献者
<a href="https://github.com/eryajf/learn-github/graphs/contributors">
<img src="https://contrib.rocks/image?repo=eryajf/learn-github" />
</a>
2
3
4
5
实际展示效果如下:
点击之后会自动跳转到贡献者列表详情中。
我的博客即将同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=3trzr4tra4aoc (opens new window)
Recommend
-
9
利用GitHub Actions实现Blog自动部署与发布 发表于 2020-06-08 | 分类于 技术控 |
-
11
利用GitHub Actions实现版本自动构建与发布流程 发表于 2022-05-02 | 分类于 技术控 |
-
8
利用GitHub Actions自动为README添加TOC目录原创 GitHub的Markdown目前不支持直接[TOC]渲染文章的目录,有些README则需要这样的效果,可以借助外部工具进行生成,也可以借助 GitHub Actions 自动生成,本文就介绍这种方式。...
-
7
-
6
-
10
GitHub 项目遭到“有毒”言论攻击,核心开源贡献者被迫出走!
-
5
-
5
-
7
-
6
V2EX › 程序员 GitHub 用户来领空投: TOP 5k 项目的贡献者可领取价值 $200 空投
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK