-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Discord GFI webhook #12436
Discord GFI webhook #12436
Conversation
WalkthroughThe recent update integrates a system to fetch new "good first issues" from GitHub and share them on Discord. It involves adding necessary configurations, setting up a GitHub Actions workflow for automation, and creating a script to fetch and send these issues to Discord. This integration aims to streamline the process of highlighting beginner-friendly contributions on Discord. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@coderabbitai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files ignored due to path filters (1)
package.json
is excluded by:!**/*.json
Files selected for processing (4)
- .env.example (1 hunks)
- .github/workflows/gfi-discord-webhook.yml (1 hunks)
- src/lib/api/fetchGFIs.ts (1 hunks)
- src/scripts/gfi-discord-webhook.ts (1 hunks)
Check Runs (1)
label completed (2)
Additional comments: 8
.github/workflows/gfi-discord-webhook.yml (2)
- 3-6: The cron schedule is set to run hourly. Consider if this frequency aligns with the project's needs for posting GFIs to Discord. Too frequent updates might overwhelm the channel, while too infrequent might miss timely engagement opportunities.
- 18-22: Ensure that the
yarn discord-issues
command correctly references the script intended to be executed. Additionally, verify that the secrets used here are correctly set up in the repository's settings to avoid runtime errors.src/lib/api/fetchGFIs.ts (2)
- 16-39: The
fetchGFIs
function correctly fetches issues from GitHub using the provided parameters and handles errors. However, consider adding more detailed logging or error handling for specific HTTP status codes to improve maintainability and debugging.- 24-24: Using a read-only token (
ISSUES_GITHUB_TOKEN_READ_ONLY
) is a good practice for security, as it minimizes potential damage if the token is compromised. Ensure this token has the minimal permissions necessary for fetching issues..env.example (1)
- 33-40: The added configurations for Discord and GitHub tokens are clear and follow best practices for sensitive data management by not including actual values in the example file. Ensure that the actual
.env
file is properly secured and not included in version control.src/scripts/gfi-discord-webhook.ts (3)
- 5-5: Loading environment variables from
.env.local
is a good practice for local development. Ensure that for production deployments, the environment variables are securely provided by the deployment environment or CI/CD pipeline.- 48-58: The POST request to the Discord webhook URL is correctly formatted. However, consider adding error handling for specific error responses from Discord to provide more detailed feedback in case of failures.
- 46-46: Ensure that the
DISCORD_ID
andDISCORD_TOKEN
are securely managed and have the minimal permissions necessary for posting messages to the designated Discord channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (3)
- .github/workflows/gfi-discord-webhook.yml (1 hunks)
- src/lib/api/fetchGFIs.ts (1 hunks)
- src/scripts/gfi-discord-webhook.ts (1 hunks)
Check Runs (1)
label completed (2)
Files skipped from review as they are similar to previous changes (3)
- .github/workflows/gfi-discord-webhook.yml
- src/lib/api/fetchGFIs.ts
- src/scripts/gfi-discord-webhook.ts
|
||
import { fetchGFIs } from "../lib/api/fetchGFIs" | ||
|
||
dotenv.config({ path: `.env.local` }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dotenv.config({ path: `.env.local` }) | |
dotenv.config() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dotenv.config({ path: `.env.local` }) | |
import "dotenv/config" |
@@ -0,0 +1,61 @@ | |||
import * as dotenv from "dotenv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we won't need this
import * as dotenv from "dotenv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (3)
- .github/workflows/gfi-discord-webhook.yml (1 hunks)
- src/lib/utils/gh.ts (1 hunks)
- src/scripts/gfi-discord-webhook.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- .github/workflows/gfi-discord-webhook.yml
- src/scripts/gfi-discord-webhook.ts
const LABELS_TO_SEARCH = ["content", "design", "dev", "doc", "translation"] | ||
const LABELS_TO_TEXT = { | ||
content: "content", | ||
design: "design", | ||
dev: "dev", | ||
doc: "docs", | ||
translation: "translation", | ||
} | ||
|
||
// Given a list of labels, it returns a string with the labels that match the | ||
// LABELS_TO_SEARCH list, using the LABELS_TO_TEXT values | ||
// Example: | ||
// - ["content :pencil:", "ux design"] => "content, design" | ||
// - ["documentation :emoji:", "dev required", "good first issue"] => "docs, dev" | ||
export const rawLabelsToText = (labels: string[]) => { | ||
return labels | ||
.map((label) => { | ||
const labelIndex = LABELS_TO_SEARCH.findIndex((l) => | ||
label.toLocaleLowerCase().includes(l) | ||
) | ||
|
||
if (labelIndex === -1) { | ||
return | ||
} | ||
|
||
const labelMatched = LABELS_TO_SEARCH[labelIndex] | ||
return LABELS_TO_TEXT[labelMatched] | ||
}) | ||
.filter(Boolean) | ||
.join(", ") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rawLabelsToText
function introduces a straightforward way to convert issue labels into a more readable format. A few suggestions for improvement:
- Performance: The current implementation uses
findIndex
inside amap
, which results in O(n^2) complexity for large label lists. Consider optimizing this if the label list grows significantly. - Clarity: The function assumes all labels will be in lowercase for matching. It's a good practice to document this assumption or ensure labels are normalized before this function is called.
- Error Handling: While the function handles non-matching labels gracefully, consider adding explicit error handling or logging for unexpected inputs to aid in debugging.
Overall, the function is well-implemented but could benefit from these refinements.
import * as dotenv from "dotenv" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the getTranslationProgress.ts
script we have import "dotenv/config"
, which points to node_modules/dotenv/config.d.ts
containing export {};
... This may be all we need to get the default env vars from the workflow
import * as dotenv from "dotenv" |
|
||
import { fetchGFIs } from "../lib/api/fetchGFIs" | ||
|
||
dotenv.config({ path: `.env.local` }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dotenv.config({ path: `.env.local` }) | |
import "dotenv/config" |
# DISCORD_ID= | ||
# DISCORD_TOKEN= | ||
|
||
# Github token used for fetching good first issues | ||
# ISSUES_GITHUB_TOKEN_READ_ONLY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Discord environment (ID and token required for Discord webhook call) | |
# DISCORD_ID= | |
# DISCORD_TOKEN= | |
# Github token used for fetching good first issues | |
# ISSUES_GITHUB_TOKEN_READ_ONLY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just need to add these here: https://github.com/ethereum/ethereum-org-website/settings/secrets/actions
Closing this implementation in favor of #12500. |
Summary by CodeRabbit
.env.example
with configurations for Discord webhook and GitHub token.