File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Update Top Contributors
2+
3+ on :
4+ schedule :
5+ - cron : ' 5 0 * * *' # Runs at 00:05 UTC every day
6+ workflow_dispatch : # Allows manual trigger
7+
8+ jobs :
9+ update-contributors :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Update Contributors
14+ run : |
15+ curl -X POST ${{ secrets.VERCEL_DEPLOYMENT_URL }}/api/updateTopContributors \
16+ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
17+ -H "Content-Type: application/json"
Original file line number Diff line number Diff line change 1+ import { fetchTopThreeUsersByPullRequests } from '../../utils/fetchTopThreeUsersByPullRequests' ;
2+ import { storeTopThreeUsersInDb } from '../../utils/fetchTopUsersFromDb' ;
3+
4+ export default async function handler ( req , res ) {
5+ const authHeader = req . headers . authorization ;
6+ if ( authHeader !== `Bearer ${ process . env . GITHUB_TOKEN } ` ) {
7+ return res . status ( 401 ) . json ( { error : 'Unauthorized' } ) ;
8+ }
9+
10+ try {
11+ const data = await fetchTopThreeUsersByPullRequests ( 'fork-commit-merge/fork-commit-merge' ) ;
12+
13+ if ( data && data . length > 0 ) {
14+ await storeTopThreeUsersInDb ( data ) ;
15+ return res . status ( 200 ) . json ( { success : true , message : 'Contributors updated successfully' } ) ;
16+ }
17+
18+ return res . status ( 400 ) . json ( { error : 'No data retrieved' } ) ;
19+ } catch ( error ) {
20+ console . error ( 'Update contributors error:' , error ) ;
21+ return res . status ( 500 ) . json ( { error : 'Internal server error' } ) ;
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments