Skip to content

Commit

Permalink
ci: Add automatic update of spiderpool authors
Browse files Browse the repository at this point in the history
Signed-off-by: tao.yang <[email protected]>
  • Loading branch information
ty-dc committed May 20, 2024
1 parent 0d8872c commit 9dc826b
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 17 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/auto-update-authors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Auto Update Authors

permissions: write-all

on:
schedule:
# each day
- cron: "0 20 * * *"
workflow_dispatch:
inputs:
ref:
description: 'branch, tag, sha'
required: true
default: main

jobs:
release_notes:
runs-on: ubuntu-latest
outputs:
ref: ${{ env.REF }}
steps:
- name: Get Ref
id: get_ref
run: |
if ${{ github.event_name == 'workflow_dispatch' }}; then
echo "call by workflow_dispatch"
echo "REF=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
else
# schedule event
# use main sha for ci image tag
echo "REF=main" >> $GITHUB_ENV
fi
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.REF }}

- name: update authors of spiderpool
run: |
make update-authors
- uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true

# Allow auto-merge on general
- name: Create Pull Request
id: create_pr
uses: peter-evans/[email protected]
with:
title: "robot updates Spiderpool authors on tag: ${{ env.REF }}"
commit-message: "robot updates Spiderpool authors on tag: ${{ env.REF }}"
branch-suffix: timestamp
committer: ty-dc <[email protected]>
branch: robot/update_doc
delete-branch: true
signoff: true
token: ${{ secrets.GITHUB_TOKEN }}
labels: ${{ env.PR_LABEL }}
reviewers: ${{ env.PR_REVIWER }}
48 changes: 31 additions & 17 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
The following people, in alphabetical order, have either authored or signed
off on commits in the Spiderpool repository:

bzsuni [email protected]
cyclinder [email protected]
ErikJiang [email protected]
Fish-pro [email protected]
hobbey [email protected]
icaruswu [email protected]
ii2day [email protected]
iiiceoo [email protected]
Jeanine-tw [email protected]
lou-lan [email protected]
my-git9 [email protected]
ty-dc [email protected]
weizhoublue [email protected]
windsonsea [email protected]
yanggangtony [email protected]
yankay [email protected]
yulng [email protected]
AltarIbnL [email protected]
Aoisop [email protected]
Cyclinder [email protected]
Henry [email protected]
Hobbey W [email protected]
Icarus Wu [email protected]
Kay Yan [email protected]
Michael [email protected]
Michelle Wu [email protected]
Peter Pan [email protected]
Stella [email protected]
TaoYang [email protected]
Yanansn [email protected]
Zechun Chen [email protected]
atabcd [email protected]
bo.jiang [email protected]
bzsuni [email protected]
elonlo1024 [email protected]
ii2day [email protected]
iiiabc [email protected]
iiice_oo [email protected]
jiecloud [email protected]
lou-lan [email protected]
maao [email protected]
my-git9 [email protected]
swatchgame [email protected]
twoodpecker [email protected]
weizhouBlue [email protected]
windyIslands [email protected]
yanggang [email protected]
yulng [email protected]
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,10 @@ lint_chart_trivy:
.PHONY: build-chart
build-chart:
@ cd charts ; make

update-authors:
@echo "Updating AUTHORS file..."
@echo "The following people, in alphabetical order, have either authored or signed" > AUTHORS
@echo "off on commits in the Spiderpool repository:" >> AUTHORS
@echo "" >> AUTHORS
@tools/scripts/extract_authors.sh >> AUTHORS
43 changes: 43 additions & 0 deletions tools/scripts/extract_authors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

# Copyright 2022 Authors of spidernet-io
# SPDX-License-Identifier: Apache-2.0

# Ensure sort order doesn't depend on locale
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

# exclusion list
# Exclude bots and non-compliant lists
excluded_name=("dependabot[bot]" "root" "[email protected]")

function extract_authors() {
authors=$(git shortlog --summary \
| awk '{$1=""; print $0}' \
| sed -e 's/^ //' \
-e '/vagrant/d')

# Iterate $authors by line
IFS=$'\n'
# Exclude emails that do not meet specifications and are duplicates.
email=()
for i in $authors; do
# Skip excluded names
if [[ " ${excluded_name[@]} " =~ " ${i} " ]]; then
continue
fi
new_email=$(git log --use-mailmap --author="$i" --format="%<|(40)%aN%aE" \
| grep -v noreply.github.com \
| grep -v example.com \
| head -n 1 \
| awk '{$1=""; print $0}')
if [[ " ${email[@]} " =~ " ${new_email// /} " ]]; then
continue
else
email+=$new_email
git log --use-mailmap --author="$i" --format="%<|(40)%aN%aE" | grep -v noreply.github.com | grep -v example.com | head -n 1
fi
done
}

extract_authors | sort -u

0 comments on commit 9dc826b

Please sign in to comment.