Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contributor to test the working #6

Merged
merged 10 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/update-contributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# This is to update contributors
name: Update Contributors

on:
push:
branches:
- main
schedule:
- cron: "0 0 * * 0"

jobs:
update-contributors:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Update Contributors
run: |
cat > update_contributors.py << 'EOF'
import subprocess
import re

def normalize_name(name):
# Remove [bot] suffix
name = re.sub(r'\[bot\]$', '', name)
# Remove common CI names
if name.lower() in ['github action', 'github actions', 'github-actions']:
return None
return name.strip()

def get_contributors():
# Get all contributors from git log
git_log = subprocess.check_output(
['git', 'log', '--format="%aN|%aE"'],
universal_newlines=True
)

# Process contributors
contributors_dict = {}
for line in git_log.replace('"', '').split('\n'):
if not line:
continue

name, email = line.split('|')
name = normalize_name(name)

if not name:
continue

# Use email as key to prevent duplicates
if email not in contributors_dict:
# Get GitHub username from email or use name
username = email.split('@')[0] if '@' in email else name.lower().replace(' ', '')
contributors_dict[email] = {
'name': name,
'username': username
}

# Format contributors
formatted_contributors = []
seen_names = set() # Track seen names to prevent duplicates

for info in contributors_dict.values():
name = info['name']
username = info['username']

# Skip if we've already seen this name
if name in seen_names:
continue

seen_names.add(name)
formatted_contributors.append(f"- **{name}** - [GitHub Profile](https://github.com/{username})")

return sorted(formatted_contributors)

def update_readme(contributors):
with open('README.md', 'r') as f:
content = f.read()

# Find the contributors section
pattern = r'(## Contributors\n\n)(.*?)(\n\n## )'
replacement = f"## Contributors\n\n{''.join(c + '\n' for c in contributors)}\n\n## "

# Replace the old contributors section with new one
new_content = re.sub(pattern, replacement, content, flags=re.DOTALL)

with open('README.md', 'w') as f:
f.write(new_content)

if __name__ == "__main__":
contributors = get_contributors()
update_readme(contributors)
EOF

# Run the Python script
python update_contributors.py

- name: Commit and push if changed
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add README.md
git diff --quiet && git diff --staged --quiet || (git commit -m "Update contributors list" && git push)
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
</div>

## Introduction

**CampX** is a web application designed to help users discover and share campgrounds from around the world. Users can browse through a collection of campgrounds, read reviews, and contribute by adding their own. Each user has control over the campgrounds they add, with the ability to edit or delete them. The platform encourages a community-driven approach to exploring the great outdoors.

## Table of Contents

- [Introduction](#introduction)
- [Features](#features)
- [Hosted Website](#hosted-website)
Expand All @@ -24,29 +26,35 @@
- [License](#license)

## Features

- **Global Campground Discovery**: Browse campgrounds from various locations worldwide.
- **User-Generated Content**: Users can add campgrounds and reviews.
- **Edit and Delete Permissions**: Only the original author of a campground can edit or delete their entry. Admins/Maintainers of CampX can edit or delete campgrounds and delete reviews upon spam detection.
- **Edit and Delete Permissions**: Only the original author of a campground can edit or delete their entry. Admins/Maintainers of CampX can edit or delete campgrounds and delete reviews upon spam detection.
- **Interactive UI**: Engaging interface built with HTML, CSS, and JavaScript.

## Hosted Website

Visit the live version of CampX here: [CampX Website](https://campx-f9sv.onrender.com)

## Tech Stack

- **Frontend**: HTML, CSS, JavaScript
- **Backend**: Node.js, Express.js
- **Database**: MongoDB Atlas
- **Media Storage**: Cloudinary

## Installation

To set up the project locally, follow the steps mentioned in the [INSTALLATION](INSTALLATION.md) Guide.

## Usage

- **Adding a Campground**: Users can submit new campgrounds by filling out a form with details such as location, description, and uploading images.
- **Reviewing Campgrounds**: Users can add reviews to any campground, sharing their experience and feedback.
- **Editing/Deleting Campgrounds**: Only the user who added a campground can edit or delete it.

## Configuration

The application requires a few configurations to run:

- **MongoDB Atlas**: Set up a cluster and obtain the connection string.
Expand All @@ -56,6 +64,7 @@ The application requires a few configurations to run:
Ensure that your environment variables are correctly set in the `.env` file as shown in the [Installation](#installation) section.

## Dependencies

Key dependencies used in the project include:

- [Express](https://expressjs.com/) - Fast, unopinionated, minimalist web framework for Node.js.
Expand All @@ -66,9 +75,11 @@ Key dependencies used in the project include:
You can view all dependencies in the `package.json` file.

## Contributing

We welcome contributions to CampX! To get started, follow the guidelines in the [CONTRIBUTING](CONTRIBUTING.md) file.

## Contributors

- **Vignesh** - [GitHub Profile](https://github.com/Vignesh025)

## Code of Conduct
Expand All @@ -78,4 +89,5 @@ We are committed to fostering a welcoming and inclusive environment for everyone
By participating in this project, you agree to abide by our Code of Conduct.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
Loading