-
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 pull request #137 from nishant0708/linkbroke
Feature: IN DEPLOYED LINK IMAGES OF GITHUB-BADGE IS NOT WORKING #129
- Loading branch information
Showing
5 changed files
with
152 additions
and
71 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
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,34 @@ | ||
name: Update Categories on PR | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
update-categories: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Update Contributors File | ||
run: node .github/workflows/update-contributors.js ${{ github.event.pull_request.user.login }} "${{ github.event.pull_request.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 .all-contributorsrc | ||
git commit -m "Update categories for ${{ github.event.pull_request.user.login }}" | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const username = process.argv[2]; | ||
const prBody = process.argv[3]; | ||
const screenshotUrl = `https://raw.githubusercontent.com/nishant0708/awesome-github-profiles/main/screenshots/${username}.png`; | ||
|
||
// Extract selected categories from the PR body | ||
const categories = (prBody.match(/\[(x| )\] (.+)/g) || []).map(line => line.replace(/^\[(x| )\] /, '')); | ||
|
||
const contributorsFilePath = path.join(process.cwd(), '.all-contributorsrc'); | ||
const contributorsData = JSON.parse(fs.readFileSync(contributorsFilePath, 'utf8')); | ||
|
||
// Check if the user already exists in the contributors data | ||
const existingContributor = contributorsData.contributors.find(contributor => contributor.login === username); | ||
|
||
if (existingContributor) { | ||
// Update existing contributor's categories | ||
existingContributor.contributions = categories; | ||
} else { | ||
// Add a new contributor | ||
contributorsData.contributors.push({ | ||
login: username, | ||
name: username, // Customize as needed | ||
avatar_url: `https://avatars.githubusercontent.com/${username}`, | ||
ScreenShot: screenshotUrl, | ||
profile: `https://github.com/${username}`, | ||
contributions: categories | ||
}); | ||
} | ||
|
||
fs.writeFileSync(contributorsFilePath, JSON.stringify(contributorsData, null, 2)); | ||
console.log('Contributors file updated successfully!'); |
Oops, something went wrong.