@@ -5,6 +5,10 @@ import { graphql } from '@octokit/graphql'
55import { execSync } from 'child_process'
66import { Octokit } from '@octokit/rest'
77
8+ // Get config
9+ const GH_USERNAME = core . getInput ( 'GH_USERNAME' )
10+ const COMMIT_NAME = core . getInput ( 'COMMIT_NAME' )
11+ const COMMIT_EMAIL = core . getInput ( 'COMMIT_EMAIL' )
812const token = process . env . GITHUB_TOKEN
913const octokit = new Octokit ( { auth : token } )
1014
@@ -57,7 +61,7 @@ async function fetchSponsoredProfiles(): Promise<SponsoredProfile[]> {
5761
5862 return sponsoredProfiles
5963 } catch ( error : any ) {
60- core . setFailed ( ' Error fetching sponsored profiles:' , error . message )
64+ core . setFailed ( ` Error fetching sponsored profiles: ${ error . message } ` )
6165 return [ ]
6266 }
6367}
@@ -67,10 +71,9 @@ async function commitIfNotDuplicate(commitMessage: string, filePath: string) {
6771 if ( ! repo ) {
6872 throw new Error ( 'GITHUB_REPOSITORY is not defined' )
6973 }
70- const owner = repo . split ( '/' )
7174
7275 const { data : commits } = await octokit . repos . listCommits ( {
73- owner,
76+ owner : GH_USERNAME ,
7477 repo,
7578 per_page : 100
7679 } )
@@ -81,10 +84,8 @@ async function commitIfNotDuplicate(commitMessage: string, filePath: string) {
8184
8285 if ( ! duplicateCommit ) {
8386 // Commit the changes
84- execSync ( 'git config --global user.name "github-actions[bot]"' )
85- execSync (
86- 'git config --global user.email "github-actions[bot]@users.noreply.github.com"'
87- )
87+ execSync ( `git config --global user.name "${ COMMIT_NAME } "` )
88+ execSync ( `git config --global user.email "${ COMMIT_EMAIL } "` )
8889 execSync ( `git add ${ filePath } ` )
8990 execSync ( `git commit -m "${ commitMessage } "` )
9091 execSync ( 'git push' )
@@ -115,7 +116,7 @@ export async function run(): Promise<void> {
115116 const filePath = `${ year } /${ month } /sponsoredProfile_${ profile . sponsorLogin } .json`
116117 fs . writeFileSync ( filePath , JSON . stringify ( profile , null , 2 ) )
117118
118- const commitMessage = `${ profile . sponsorshipAmount } ${ profile . currency } sponsorship paid to @${ profile . sponsorLogin } for ${ month } ${ year } `
119+ const commitMessage = `${ profile . sponsorshipAmount } ${ profile . currency } paid to @${ profile . sponsorLogin } for ${ month } ${ year } to support open source. `
119120
120121 await commitIfNotDuplicate ( commitMessage , filePath )
121122 } )
0 commit comments