Skip to content

Commit

Permalink
Merge pull request #137 from nishant0708/linkbroke
Browse files Browse the repository at this point in the history
Feature: IN DEPLOYED LINK IMAGES OF GITHUB-BADGE IS NOT WORKING #129
  • Loading branch information
sanjay-kv authored Aug 6, 2024
2 parents df9472c + eae46ae commit 2e9ba06
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 71 deletions.
24 changes: 19 additions & 5 deletions .github/ISSUE_TEMPLATE/add_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@ 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
## Profile Submission

enter category to label your profile
category:
Please paste a screenshot of your GitHub profile here.

then comment ``@all-contributors please add @<username> for review``
### Profile Category
Please select one or more categories for your profile:

- [ ] <span class="tag">Badge 🎖️</span>
- [ ] <span class="tag">Minimalistic ✨</span>
- [ ] <span class="tag">Dynamic 🔄</span>
- [ ] <span class="tag">Icons 🎯</span>
- [ ] <span class="tag">Backgrounds 😎</span>
- [ ] <span class="tag">GIFS 🖼️</span>
- [ ] <span class="tag">Game Mode 🚀</span>
- [ ] <span class="tag">Code 👨‍💻</span>

### Next Steps

Once you've filled out the information, please comment below:

``@all-contributors please add @<username> for review``

34 changes: 34 additions & 0 deletions .github/workflows/update-categories.yml
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 }}
33 changes: 33 additions & 0 deletions .github/workflows/update-contributors.js
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!');
Loading

0 comments on commit 2e9ba06

Please sign in to comment.