-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into all-contributors/add-dinxsh
- Loading branch information
Showing
4 changed files
with
189 additions
and
7 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,13 @@ | ||
--- | ||
name: ➕ Add Profile | ||
about: Add your profile to our database ✨ | ||
title: "Add Profile: " | ||
labels: ➕ profile | ||
category: String | ||
--- | ||
|
||
paste a screenshot of your GitHub profile here | ||
|
||
enter category to label your profile | ||
category: | ||
|
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,43 @@ | ||
const fs = require('fs'); | ||
const jsonfile = require('jsonfile'); | ||
const path = require('path'); | ||
|
||
// Path to your contributors.json file | ||
const contributorsFilePath = path.resolve(__dirname, '../../path/to/your/contributors.json'); | ||
|
||
const username = process.argv[2]; | ||
const issueBody = process.argv[3]; | ||
|
||
// Regular expression to extract image URL from issue body | ||
const imageUrlRegex = /(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/i; | ||
const imageUrlMatch = issueBody.match(imageUrlRegex); | ||
const imageUrl = imageUrlMatch ? imageUrlMatch[0] : ''; | ||
|
||
if (!imageUrl) { | ||
console.error('No image URL found in the issue body.'); | ||
process.exit(1); | ||
} | ||
|
||
jsonfile.readFile(contributorsFilePath, (err, data) => { | ||
if (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
|
||
const contributorExists = data.contributors.some(contributor => contributor.username === username); | ||
|
||
if (!contributorExists) { | ||
data.contributors.push({ username, image: imageUrl }); | ||
|
||
jsonfile.writeFile(contributorsFilePath, data, { spaces: 2 }, err => { | ||
if (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
|
||
console.log('Contributor added successfully!'); | ||
}); | ||
} else { | ||
console.log('Contributor already exists.'); | ||
} | ||
}); |
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,33 @@ | ||
name: Add Contributor on Issue | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
add-contributor: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
|
||
- name: Run script to add contributor | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
npm install -g jsonfile | ||
node .github/scripts/addContributor.js "${{ github.event.issue.user.login }}" "${{ github.event.issue.body }}" | ||
- name: Commit and push changes | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add . | ||
git commit -m "Add contributor: ${{ github.event.issue.user.login }}" | ||
git push |
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