-
Notifications
You must be signed in to change notification settings - Fork 8
125 lines (106 loc) · 4.5 KB
/
pull-maintainers-from-database-and-make-a-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: "Sync maintainers status"
# Script connects to the contacts database every 8 hours and updates
# BOARD_MAINTAINER property in the board config files. If there are any changes,
# it opens a Pull Request to https://github.com/armbian/build
#
# spdx-id: GPL-2.0-or-later
# copyright-owner: Igor Pecovnik
# Dependencies: lftp, jq
on:
schedule:
- cron: "0 * * * *"
workflow_dispatch:
jobs:
Build:
name: Maintainers sync
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'armbian' }}
steps:
- name: Checkout build repo
uses: actions/checkout@v4
with:
repository: armbian/build
ref: main
fetch-depth: 0
clean: false
- name: Install SSH key for storage
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.KEY_UPLOAD }}
known_hosts: ${{ secrets.KNOWN_HOSTS_ARMBIAN_UPLOAD }}
if_key_exists: replace
- name: Install dependencies
run: |
# install dependencies
sudo apt-get -y -qq install jq
- name: Download armbian_maintainers.json
run: |
# download json that is prepared for this action in another cron job
rsync -e "ssh -p ${{ secrets.HOST_UPLOAD_PORT }}" -arvc ${{ secrets.HOST_UPLOAD_USER }}@${{ secrets.HOST_UPLOAD }}:/incoming/json/armbian_maintainers.json /tmp/
- name: Update maintainers
run: |
# reset all maintainers so we generate from scratch
sed -i "s/BOARD_MAINTAINER.*/BOARD_MAINTAINER=\"\"/" config/boards/*.{conf,wip,eos,tvb}
# extract values fron JSON
declare -A MAINTAINERS
{
# By default, bash run the pipe command in subshells
# which make variable can't be assigned to.
# And yes, lastpipe can solve it
# But this is better.
while read -r i; do
NAME="$(echo "$i" | jq --raw-output '.First_Name')"
BOARD="$(echo "$i" | jq --raw-output '.Maintaining')"
MAINTAINER_GITHUB="$(echo "$i" | jq --raw-output '.Github' | cut -d"/" -f4)"
if [[ "$BOARD" != null && "$MAINTAINER_GITHUB" != null ]]; then
echo "- [$NAME](https://github.com/${MAINTAINER_GITHUB})"
while read -r i; do
echo -e " - $i"
MAINTAINERS["$i"]+="$MAINTAINER_GITHUB "
done < <( echo "$BOARD" | sed "s/,/\n/g" | sort -u )
fi
done < <(jq -c '.[]' /tmp/armbian_maintainers.json)
for cfg in config/boards/*.{conf,wip,csc,eos,tvb}; do
board_name="$(echo "${cfg##*/}" | sed -E 's/\..*//')"
declare -a maintainers
readarray -t maintainers < <(echo "${MAINTAINERS[${board_name}]}" | xargs -n1 | sort -u)
sed -i "s/BOARD_MAINTAINER=.*/BOARD_MAINTAINER=\"${maintainers[*]}\"/" "${cfg}"
done
} >> "$GITHUB_STEP_SUMMARY"
- name: Mark csc for no maintainer
run: |
grep BOARD_MAINTAINER=\"\" config/boards/*.{wip,conf} | cut -d":" -f1 |
while read -r line; do
if [[ "${line}" != "${line/.conf/.csc}" ]]; then
mv -v "$line" "${line/.conf/.csc}"
fi
if [[ "${line}" != "${line/.wip/.csc}" ]]; then
mv -v "$line" "${line/.wip/.csc}"
fi
done
- name: Re-generate CODEOWNERS
run: |
./.github/generate_CODEOWNERS.sh
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.ACCESS_TOKEN }}
commit-message: '`Automatic` board configs status synchronise'
#committer: Armbianworker <[email protected]>
#author: armbianworker <[email protected]>
signoff: false
branch: update-maintainers
delete-branch: true
title: '`Automatic` board configs status synchronise'
body: |
Update maintainers and board status
- synced status from the database
- rename to .`csc` where we don't have anyone
If you want to become a board maintainer, [adjust data here](https://www.armbian.com/update-data/).
Ref: [Board Maintainers Procedures and Guidelines](https://docs.armbian.com/Board_Maintainers_Procedures_and_Guidelines/)
labels: |
Needs review
#assignees: igorpecovnik
#reviewers: Must be org collaborator
draft: false