1
+ name : Generate Bigin JSONs
2
+
3
+ on :
4
+ repository_dispatch :
5
+ types : ["Bigin update"]
6
+
7
+ concurrency :
8
+ group : redirector
9
+ cancel-in-progress : false
10
+
11
+ jobs :
12
+ fetch-bigin-data :
13
+ runs-on : ubuntu-latest
14
+ name : " Fetch data"
15
+ steps :
16
+ - name : Checkout armbian.github.io repository
17
+ uses : actions/checkout@v4
18
+ with :
19
+ repository : armbian/armbian.github.io
20
+ fetch-depth : 0
21
+ clean : false
22
+ path : armbian.github.io
23
+
24
+ - name : Fetch and generate partner JSON files
25
+ env :
26
+ CLIENT_ID : ${{ secrets.ZOHO_CLIENT_ID }}
27
+ CLIENT_SECRET : ${{ secrets.ZOHO_CLIENT_SECRET }}
28
+ REFRESH_TOKEN : ${{ secrets.ZOHO_REFRESH_TOKEN }}
29
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
30
+ run : |
31
+ ACCESS_TOKEN=$(curl -sH "Content-type: multipart/form-data" \
32
+ -F refresh_token=$REFRESH_TOKEN \
33
+ -F client_id=$CLIENT_ID \
34
+ -F client_secret=$CLIENT_SECRET \
35
+ -F grant_type=refresh_token \
36
+ -X POST https://accounts.zoho.eu/oauth/v2/token \
37
+ | jq -r '.access_token')
38
+
39
+ echo "Access token obtained."
40
+
41
+ curl --silent --request GET \
42
+ --url 'https://www.zohoapis.eu/bigin/v2/Accounts/search?fields=Website,Logo,Description,Account_Name,Email,Partnership_Status,Promoted&criteria=((Partnership_Status:equals:Platinum%20Partner)and(Promoted:equals:true))' \
43
+ --header "Authorization: Zoho-oauthtoken $ACCESS_TOKEN" \
44
+ | jq '.data[] | {Account_Name, Logo, Website, Description, Promoted}' > platinum-partner.json
45
+
46
+ curl --silent --request GET \
47
+ --url 'https://www.zohoapis.eu/bigin/v2/Accounts/search?fields=Website,Logo,Description,Account_Name,Email,Partnership_Status&criteria=((Partnership_Status:equals:Gold%20Partner)and(Promoted:equals:true))' \
48
+ --header "Authorization: Zoho-oauthtoken $ACCESS_TOKEN" \
49
+ | jq '.data[] | {Account_Name, Logo, Website, Description}' > gold-partner.json
50
+
51
+ curl --silent --request GET \
52
+ --url 'https://www.zohoapis.eu/bigin/v2/Accounts/search?fields=Website,Logo,Description,Account_Name,Email,Partnership_Status&criteria=((Partnership_Status:equals:Silver%20Partner)and(Promoted:equals:true))' \
53
+ --header "Authorization: Zoho-oauthtoken $ACCESS_TOKEN" \
54
+ | jq '.data[] | {Account_Name, Logo, Website, Description}' > silver-partner.json
55
+
56
+ # Create a temporary file for maintainers_with_avatars.json
57
+ temp_file=$(mktemp)
58
+
59
+ # Start the JSON array
60
+ echo "[" > "$temp_file"
61
+
62
+ # Flag for commas between records
63
+ first=1
64
+
65
+ # Fetch the maintainers from Zoho Bigin
66
+ curl --silent --request GET \
67
+ --url 'https://www.zohoapis.eu/bigin/v2/Contacts/search?fields=Team,First_Name,Github,Maintaining,Your_core_competences&criteria=((Tag:equals:maintainer)and(Email_Opt_Out:equals:false))' \
68
+ --header "Authorization: Zoho-oauthtoken $ACCESS_TOKEN" \
69
+ | jq -c '.data[] | {First_Name, Github, Team, Maintaining, Your_core_competences}' \
70
+ | while read -r row; do
71
+ # Extract GitHub username from the URL
72
+ github_url=$(echo "$row" | jq -r '.Github')
73
+ username=$(basename "$github_url")
74
+
75
+ # Assume GH_TOKEN is exported as env var or injected from GitHub Actions secrets
76
+ auth_header="Authorization: token $GH_TOKEN"
77
+
78
+ # Fetch GitHub profile for avatar URL
79
+ avatar_url=$(curl -s -H "$auth_header" "https://api.github.com/users/$username" | jq -r '.avatar_url')
80
+
81
+ # Enrich Zoho data with GitHub avatar
82
+ enriched=$(echo "$row" | jq --arg avatar "$avatar_url" '. + {Avatar: $avatar}')
83
+
84
+ # Manage commas between JSON objects
85
+ if [ $first -eq 1 ]; then
86
+ first=0
87
+ else
88
+ echo -e "," >> "$temp_file"
89
+ fi
90
+
91
+ # Write the enriched data to the temporary file
92
+ echo "$enriched" >> "$temp_file"
93
+ done
94
+
95
+ # Close the JSON array
96
+ echo "]" >> "$temp_file"
97
+
98
+ # Format and save the final output to fixed.json
99
+ cat "$temp_file" | jq . > maintainers.json
100
+
101
+ # Clean up the temporary file
102
+ rm "$temp_file"
103
+
104
+ - name : Commit and push JSON files
105
+ run : |
106
+
107
+ cd armbian.github.io
108
+ git checkout data
109
+ mkdir -p data/
110
+
111
+ cp ${{ github.workspace }}/*.json data/
112
+
113
+ git config user.name "github-actions[bot]"
114
+ git config --global user.email "[email protected] "
115
+ git add platinum-partner.json gold-partner.json silver-partner.json maintainers.json
116
+ git commit -m "Update of Bigin sourced JSON files" || echo "No changes to commit"
117
+ git push
118
+
119
+ - name : " Run base-files update action"
120
+ uses : peter-evans/repository-dispatch@v3
121
+ with :
122
+ token : ${{ secrets.GITHUB_TOKEN }}
123
+ event-type : " Base files"
0 commit comments