-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add contributors react component in the website (#163)
* ⚙️ added script for fetching contributors * 🛠️ Added gh workflow for fetching contributors every midnight * aaded react component for contributors * 🚃 moved contributors section from home page to about us page * 🛠️ Rectified about us * Update src/components/Contributors/styles.module.css * ⚡ rectified the section style * Update src/components/Contributors/styles.module.css --------- Co-authored-by: Abhijay Jain <[email protected]>
- Loading branch information
1 parent
0f00faf
commit 981d243
Showing
7 changed files
with
5,592 additions
and
0 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,23 @@ | ||
name: Fetch Contributors | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * *" # Run every day at midnight | ||
|
||
jobs: | ||
fetch-contributors: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "14" | ||
|
||
- name: Run Fetch Contributors Script | ||
run: node scripts/fetchContributors.js | ||
env: | ||
ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,45 @@ | ||
const axios = require('axios'); | ||
const fs = require('fs'); | ||
|
||
const accessToken = process.env.REACT_APP_GITHUB_ACCESS_TOKEN; | ||
|
||
const getRepositories = async () => { | ||
const url = `https://api.github.com/orgs/uptane/repos`; | ||
const response = await axios.get(url, { | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); | ||
return response.data; | ||
} | ||
|
||
const getContributors = async (repoName) => { | ||
const url = `https://api.github.com/repos/uptane/${repoName}/contributors`; | ||
const response = await axios.get(url, { | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); | ||
return response.data; | ||
} | ||
|
||
const fetchContributors = async () => { | ||
try { | ||
const repositories = await getRepositories(); | ||
|
||
const contributorsList = []; | ||
|
||
for (const repo of repositories) { | ||
const contributors = await getContributors(repo.name); | ||
contributorsList.push({ repository: repo.name, contributors }); | ||
} | ||
|
||
const jsonContent = JSON.stringify(contributorsList, null, 2); | ||
fs.writeFileSync('./contributors.json', jsonContent); | ||
console.log('SUCCESS :: scripts/fetchContributors.js :: Contributors list saved to contributors.json'); | ||
} catch (error) { | ||
console.error('ERROR :: scripts/fetchContributors.js :: ', error.message); | ||
} | ||
} | ||
|
||
fetchContributors(); |
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,39 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import styles from './styles.module.css'; | ||
import ContributorList from './../../../contributors.json'; | ||
|
||
const Contributors = () => { | ||
|
||
const [allContributors, setAllContributors] = useState([]); | ||
|
||
useEffect(() => { | ||
const uniqueContributors = new Map(); | ||
|
||
for (const repo of ContributorList) { | ||
repo.contributors.forEach((contributor) => { | ||
uniqueContributors.set(contributor.id, contributor); | ||
}); | ||
} | ||
|
||
const uniqueContributorsArray = Array.from(uniqueContributors.values()); | ||
|
||
setAllContributors(uniqueContributorsArray); | ||
}, []); | ||
|
||
return <div className={[styles.contributors].join(' ')}> | ||
<div className={styles.uptane_contributors}> | ||
<h1>Uptane Contributors</h1> | ||
</div> | ||
<div className={styles.contributor_list}> | ||
{ | ||
allContributors.map((contributor) => ( | ||
<a className={styles.contributor} href={contributor?.html_url} target="_blank"> | ||
<img src={contributor?.avatar_url} /> | ||
</a> | ||
)) | ||
} | ||
</div> | ||
</div> | ||
} | ||
|
||
export default Contributors; |
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,50 @@ | ||
.contributors { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.uptane_contributors { | ||
width: 100%; | ||
text-align: center; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
margin-bottom: 2rem; | ||
} | ||
|
||
.uptane_contributors h1 { | ||
font-weight: 600; | ||
font-size: 40px; | ||
line-height: 55px; | ||
color: var(--ifm-color-primary); | ||
} | ||
|
||
.contributor_list { | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 2em; | ||
padding: 0; | ||
} | ||
|
||
.contributor { | ||
height: 70px; | ||
width: 70px; | ||
border-radius: 50%; | ||
border: 2px solid var(--ifm-color-primary); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.contributor img { | ||
height: 60px; | ||
width: 60px; | ||
border-radius: 50%; | ||
object-fit: cover; | ||
} |
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