From ead1091acab56e8a87ebe0f5ff36339c45bd4fa0 Mon Sep 17 00:00:00 2001 From: Rizel Scarlett Date: Mon, 30 Sep 2024 19:51:17 -0400 Subject: [PATCH] Update websitetoissue.yml --- .github/workflows/websitetoissue.yml | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/websitetoissue.yml b/.github/workflows/websitetoissue.yml index 8a21977..17c4da8 100644 --- a/.github/workflows/websitetoissue.yml +++ b/.github/workflows/websitetoissue.yml @@ -2,8 +2,8 @@ name: Update Hacktoberfest Leaderboard on: schedule: - - cron: '0 */6 * * *' - workflow_dispatch: + - cron: '0 */6 * * *' # Runs every 6 hours + workflow_dispatch: # Allows manual triggering jobs: update-leaderboard: @@ -31,14 +31,14 @@ jobs: from bs4 import BeautifulSoup # Fetch data from the website - website_url = "https://leaderboard-nk9strn08-blackgirlbytes-projects.vercel.app" + website_url = "https://your-website-url.com" # Replace with your actual website URL response = requests.get(website_url) soup = BeautifulSoup(response.text, 'html.parser') # Extract table data - table = soup.find('table') - rows = table.find_all('tr')[1:] - + table = soup.find('table') # Adjust this if your table has a specific class or id + rows = table.find_all('tr')[1:] # Skip header row + # Format data for GitHub issue leaderboard_content = "| Rank | Username | Points | PRs |\n" leaderboard_content += "|------|----------|--------|-----|\n" @@ -47,24 +47,25 @@ jobs: leaderboard_content += f"| {cols[0].text.strip()} | {cols[1].text.strip()} | {cols[2].text.strip()} | {cols[3].text.strip()} |\n" # GitHub API request to update the issue - issue_url = "https://api.github.com/repos/galaxy-bytes/main-test-repo/issues/1" + issue_url = "https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER" # Replace with your actual issue URL + headers = { "Authorization": f"token {os.environ['GITHUB_TOKEN']}", "Accept": "application/vnd.github.v3+json" } issue_content = f"""# 🏆 TBD Hacktoberfest 2024 Leaderboard 🏆 -Hello, lovely contributors! As Hacktoberfest 2024 and the crisp Fall breeze refreshes us, we wanted to make the contribution process extra fun. Check our live leaderboard below to see who our top contributors are this year in real-time. Not only does this recognize everyones efforts, it also brings an amplified competitive vibe with each contribution. + Hello, lovely contributors! As Hacktoberfest 2024 and the crisp Fall breeze refreshes us, we wanted to make the contribution process extra fun. Check our live leaderboard below to see who our top contributors are this year in real-time. Not only does this recognize everyone's efforts, it also brings an amplified competitive vibe with each contribution. -### 🌟 **Current Rankings:** -{leaderboard_content} -### 📜 How It Works: -The top 10 contributors with the most points will snag custom swag with this year's exclusive TBD x Hacktoberfest 2024 design. To earn your place in the leaderboard, we have created a points system that is explained below. As you complete a task by successfully merging a PR, you will automatically be granted a certain number of points. + ### 🌟 **Current Rankings:** + {leaderboard_content} + ### 📜 How It Works: + The top 10 contributors with the most points will snag custom swag with this year's exclusive TBD x Hacktoberfest 2024 design. To earn your place in the leaderboard, we have created a points system that is explained below. As you complete a task by successfully merging a PR, you will automatically be granted a certain number of points. -#### 💯 Point System -| Weight | Points Awarded | Description | -|--------|----------------|-------------| -| 🐭 **Small** | 5 points | For smaller tasks that take limited time to complete and/or don't require any product knowledge. | -""" + #### 💯 Point System + | Weight | Points Awarded | Description | + |--------|----------------|-------------| + | 🐭 **Small** | 5 points | For smaller tasks that take limited time to complete and/or don't require any product knowledge. | + """ # Update the issue response = requests.patch(issue_url, headers=headers, json={"body": issue_content})