-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74a8f26
commit 8e3510c
Showing
1 changed file
with
19 additions
and
18 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 |
---|---|---|
|
@@ -10,10 +10,7 @@ const contributorsFile = 'contributors.json'; | |
async function updateContributors() { | ||
try { | ||
const response = await axios.get(`https://api.github.com/repos/${owner}/${repo}/contributors`); | ||
const contributors = response.data.map(contributor => { | ||
console.log(contributor); | ||
return contributor.login; | ||
}); | ||
const contributors = response.data.map(contributor => contributor.login); | ||
|
||
let existingContributors = []; | ||
|
||
|
@@ -23,26 +20,30 @@ async function updateContributors() { | |
|
||
const updatedContributors = [...new Set(existingContributors.concat(contributors))]; | ||
|
||
fs.writeFileSync(contributorsFile, JSON.stringify(updatedContributors, null, 2)); | ||
console.log('Contributors file updated.'); | ||
if (JSON.stringify(existingContributors) !== JSON.stringify(updatedContributors)) { | ||
fs.writeFileSync(contributorsFile, JSON.stringify(updatedContributors, null, 2)); | ||
console.log('Contributors file updated.'); | ||
|
||
// Add the commit and push logic | ||
const { execSync } = require('child_process'); | ||
// Add the commit and push logic | ||
const { execSync } = require('child_process'); | ||
|
||
// Configure Git user and email for the commit | ||
execSync('git config --global user.name "GitHub Action"'); | ||
execSync('git config --global user.email "[email protected]"'); | ||
// Configure Git user and email for the commit | ||
execSync('git config --global user.name "GitHub Action"'); | ||
execSync('git config --global user.email "[email protected]"'); | ||
|
||
// Stage the changes | ||
execSync('git add .'); | ||
// Stage the changes | ||
execSync('git add .'); | ||
|
||
// Create the commit | ||
execSync(`git commit -m "Update contributors.json [skip ci]"`); | ||
// Create the commit | ||
execSync(`git commit -m "Update contributors.json [skip ci]"`); | ||
|
||
// Push the changes to the repository | ||
execSync(`git push origin ${branch}`); | ||
// Push the changes to the repository | ||
execSync(`git push origin ${branch}`); | ||
|
||
console.log('Changes committed and pushed to the repository.'); | ||
console.log('Changes committed and pushed to the repository.'); | ||
} else { | ||
console.log('No changes detected in contributors. Skipping commit and push.'); | ||
} | ||
} catch (error) { | ||
console.error('Error updating contributors:', error); | ||
} | ||
|