Initial commit: 小南娘 - 面向可爱的蓝孩子的 git 学习实践项目
仿 Dress 的照片投稿仓库, 适配自建 Gitea 平台 git.xhmcl.com: - README / GUIDE (PR 教程) / CONTRIBUTING / Q&A / EXIF / PARTIAL_CLONE (中英双语) - A-Z + # 首字母目录结构 - .gitea: PR 模板、维护者名单、7 个纯 bash + API 的 Actions 工作流 (可选功能) Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
commit
cf17c9ea42
51 files changed
+2450
No files matched your search
@@ -0,0 +1,59 @@
|
||||
# Greetings
|
||||
#
|
||||
# 首次贡献者的 PR 欢迎评论.
|
||||
# 纯 shell + 平台 API 实现, 不依赖第三方 action (无需从 GitHub 拉取任何内容).
|
||||
#
|
||||
# 要求:
|
||||
# - 平台启用 Gitea Actions 并注册 ubuntu runner
|
||||
# - 若 Gitea 版本不支持 pull_request_target, 请改为 pull_request
|
||||
name: Greetings
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
greeting:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install jq
|
||||
run: |
|
||||
command -v jq && exit 0
|
||||
sudo apt-get install -y --no-install-recommends jq \
|
||||
|| (sudo apt-get update && sudo apt-get install -y --no-install-recommends jq)
|
||||
|
||||
- name: Welcome first-time contributor
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
API: ${{ gitea.server_url || 'https://git.xhmcl.com' }}/api/v1
|
||||
REPO: ${{ github.repository }}
|
||||
ACTOR: ${{ github.actor }}
|
||||
PR_NUM: ${{ github.event.pull_request.number }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
OWNER="${REPO%%/*}"
|
||||
NAME="${REPO#*/}"
|
||||
|
||||
api() {
|
||||
curl -fsS -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" "$@"
|
||||
}
|
||||
|
||||
# 统计该用户提交过的 PR 总数 (分页遍历)
|
||||
total=0
|
||||
page=1
|
||||
while :; do
|
||||
resp=$(api "$API/repos/$OWNER/$NAME/pulls?state=all&poster=$ACTOR&limit=50&page=$page")
|
||||
n=$(echo "$resp" | jq 'if type=="array" then length else 0 end')
|
||||
total=$((total + n))
|
||||
[ "$n" -lt 50 ] && break
|
||||
page=$((page + 1))
|
||||
done
|
||||
|
||||
if [ "$total" -le 1 ]; then
|
||||
body=$(jq -n --arg u "@$ACTOR" \
|
||||
'{"body": ("你好 " + $u + ",感谢提交PR!\nHi " + $u + ", thanks for opening the Pull Request!\n我们会尽早审核回应😊\nWe will respond to it as soon as possible😊")}')
|
||||
api -X POST -d "$body" "$API/repos/$OWNER/$NAME/issues/$PR_NUM/comments"
|
||||
echo "Welcome comment posted for first PR of $ACTOR."
|
||||
else
|
||||
echo "Not the first PR of $ACTOR ($total PRs), skip."
|
||||
fi
|
||||
Reference in new issue
Block a user