Skip to content

Commit

Permalink
Merge branch 'main' into gssoc-25
Browse files Browse the repository at this point in the history
  • Loading branch information
Unnimaya6122004 authored Aug 3, 2024
2 parents 0e375a1 + d337617 commit 877d5c8
Show file tree
Hide file tree
Showing 75 changed files with 18,405 additions and 10,724 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/check_duplicate_tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Check for Duplicates and Close Issues on PR Merge

on:
pull_request:
types: [opened, synchronize, closed]

jobs:
check-duplicates:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Check for duplicate entries in product.json
run: |
# Check for duplicate entries in product.json
jq -r '.[].productName' product.json | sort | uniq -d > duplicates.txt
if [ -s duplicates.txt ]; then
echo "Duplicate entries found in product.json:"
cat duplicates.txt
exit 1
else
echo "No duplicate entries found."
fi
close-issues:
runs-on: ubuntu-latest
needs: check-duplicates
if: github.event.pull_request.merged == true

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Close linked issues
run: |
ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#')
for ISSUE in $ISSUES
do
echo "Closing issue #$ISSUE"
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE/comments \
-d '{"body":"Closed by PR #${{ github.event.pull_request.number }}"}'
curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE \
-d '{"state":"closed"}'
done
119 changes: 59 additions & 60 deletions backend/init/sampleToolsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,66 @@ const mongoose = require("mongoose");
const { connectToDB } = require("../src/config/database");
const Tool = require("../src/models/Tool");

async function db(){
await connectToDB();
}

db()
async function db() {
try {
await connectToDB();
console.log("Database connected!");

const sampleData = [
new Tool({
productName: "Carousel Hero",
category: "tools",
image: "https://i.ibb.co/7rRW6TW/logo-social-large.png",
link: "https://carouselhero.com",
description: "Create social media carousels for free and with no signup.",
}),
new Tool({
productName: "PikaShows",
category: "movies",
image: "https://tinyurl.com/37csr8my",
link: "https://www.pikashows.download/",
description:
"Download this application for PC and Mobile to stream all types of TV Shows and Movies.",
}),
new Tool({
productName: "Scaler",
category: "coding",
image: "https://bit.ly/3XoZKgc",
link: "https://bit.ly/3plUFZw",
description: "Scaler is an outcome-focused, ed-tech platform for techies.",
}),
new Tool({
productName: "InterviewBit",
category: "coding",
image: "https://bit.ly/3NH8dIt",
link: "https://bit.ly/43VBwNf",
description:
"InterviewBit prepares you not only for the interviews, but for the actual job too.",
}),
new Tool({
productName: "Momentum",
category: "extensions",
image: "https://bit.ly/3JoG8mI",
link: "https://bit.ly/3JoG6v6",
description:
"Replace new tab page with a personal dashboard to help you get focused, stay organized, and keep motivated to achieve your goals.",
}),
const sampleData = [
{
productName: "Carousel Hero",
category: "tools",
image: "https://i.ibb.co/7rRW6TW/logo-social-large.png",
link: "https://carouselhero.com",
description: "Create social media carousels for free and with no signup.",
},
{
productName: "PikaShows",
category: "movies",
image: "https://tinyurl.com/37csr8my",
link: "https://www.pikashows.download/",
description: "Download this application for PC and Mobile to stream all types of TV Shows and Movies.",
},
{
productName: "Scaler",
category: "coding",
image: "https://bit.ly/3XoZKgc",
link: "https://bit.ly/3plUFZw",
description: "Scaler is an outcome-focused, ed-tech platform for techies.",
},
{
productName: "InterviewBit",
category: "coding",
image: "https://bit.ly/3NH8dIt",
link: "https://bit.ly/43VBwNf",
description: "InterviewBit prepares you not only for the interviews, but for the actual job too.",
},
{
productName: "Momentum",
category: "extensions",
image: "https://bit.ly/3JoG8mI",
link: "https://bit.ly/3JoG6v6",
description: "Replace new tab page with a personal dashboard to help you get focused, stay organized, and keep motivated to achieve your goals.",
},
{
productName: "ACM",
category: "tools",
image: "https://avatars.githubusercontent.com/u/65459277?s=200&v=4",
link: "https://www.acm.org/",
description: "It provides a platform for computing professionals, researchers, educators, and students to exchange ideas and information related to computer science and information technology.",
},
];

const insertedData = await Tool.insertMany(sampleData);
console.log("Sample data added successfully!", insertedData);
} catch (error) {
console.error("Error adding sample data:", error);
} finally {
mongoose.connection.close(() => {
console.log("Database connection closed.");
});
}
}

new Tool({
productName: "ACM",
category: "tools",
image: "https://avatars.githubusercontent.com/u/65459277?s=200&v=4",
link: "https://www.acm.org/",
description:
"It provides a platform for computing professionals, researchers, educators, and students to exchange ideas and information related to computer science and information technology.",
}),
];
db();

Tool.insertMany(sampleData)
.then((res) => {
console.log("Added!");
})
.catch((err) => {
console.log(err);
});
Loading

0 comments on commit 877d5c8

Please sign in to comment.