Skip to content

Commit f5c287b

Browse files
committed
Generate JSON files for displaying partners
1 parent a526bfe commit f5c287b

File tree

4 files changed

+133
-1
lines changed

4 files changed

+133
-1
lines changed

.github/workflows/generate-jira-excerpt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ jobs:
4747
uses: peter-evans/repository-dispatch@v3
4848
with:
4949
token: ${{ secrets.GITHUB_TOKEN }}
50-
event-type: "Base files"
50+
event-type: "Bigin update"
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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"

.github/workflows/train-order.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Build train order
2+
3+
- generate-redirector-config.yml
4+
- generate-web-index.yml
5+
- generate-jira-excerpt.yml
6+
- generate-partners-json.yml
7+
- generate-base-files-info-json.yml
8+
- directory-listing.yml

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ It prepares several data exchange files.
2323
| [Wireless performance testing](https://docs.armbian.com/WifiPerformance/) |<a href=https://github.com/armbian/armbian.github.io/actions/workflows/wireless-performance-autotest.yml><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/armbian/armbian.github.io/wireless-performance-autotest.yml?logo=githubactions&label=Status&style=for-the-badge&branch=main"></a>|
2424
| Mirror repository artifacts to our CDN |<a href=https://github.com/armbian/armbian.github.io/actions/workflows/mirror.yml><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/armbian/armbian.github.io/mirror.yml?logo=githubactions&label=Status&style=for-the-badge&branch=main"></a>|
2525
| Invite recent contributors to organization |<a href=https://github.com/armbian/armbian.github.io/actions/workflows/invite-contributors.yml><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/armbian/armbian.github.io/invite-contributors.yml?logo=githubactions&label=Status&style=for-the-badge&branch=main"></a>|
26+
| Generate authors and partners JSON |<a href=https://github.com/armbian/armbian.github.io/actions/workflows/generate-partners-json.yml><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/armbian/armbian.github.io/generate-partners-json.yml?logo=githubactions&label=Status&style=for-the-badge&branch=main"></a>|

0 commit comments

Comments
 (0)