forked from spidernet-io/spiderpool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Add automatic update of spiderpool authors
Signed-off-by: tao.yang <[email protected]>
- Loading branch information
Showing
4 changed files
with
146 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |