docs: ignore copilot-swe-agent from contributors and fix discord release message (#1438)

This commit is contained in:
Juro Oravec 2025-10-06 10:29:34 +02:00 committed by GitHub
parent 7aeab02d64
commit 28def742ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 49 additions and 31 deletions

View file

@ -1,21 +1,37 @@
name: Notify Discord on Release
on:
push:
tags:
- '*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
releases:
types: [published]
jobs:
# See https://github.com/teneplaysofficial/releasify-action
# and https://dev.to/tene/introducing-releasify-action-announce-github-releases-on-discord-effortlessly-3132
discordNotification:
notify:
runs-on: ubuntu-latest
steps:
- name: Notify via Releasify
uses: teneplaysofficial/releasify-action@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_ANNOUNCEMENTS }}
username: "ReleaseBot"
- name: Post to Discord (announcements channel)
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_ANNOUNCEMENTS }}
run: |
payload=$(jq -n \
--arg name "${{ github.event.release.name || github.event.release.tag_name }}" \
--arg url "${{ github.event.release.html_url }}" \
--arg body "${{ github.event.release.body }}" \
--arg user "${{ github.event.release.author.login }}" \
--arg repo "${{ github.repository }}" \
--arg timestamp "${{ github.event.release.published_at }}" \
'{
"username": "GitHub Releases",
"avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
"embeds": [
{
"title": ("🚀 New Release: " + $name),
"url": $url,
"description": $body,
"color": 2664261,
"author": {"name": $user},
"footer": {"text": $repo},
"timestamp": $timestamp
}
]
}')
curl -sS -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" | cat

View file

@ -20,9 +20,20 @@ from pydantic_settings import BaseSettings
logger = logging.getLogger(__name__)
github_graphql_url = "https://api.github.com/graphql"
MAINTAINER_USERS = {
"EmilStenstrom",
"JuroOravec",
}
BOT_USERS = {
"dependabot",
"github-actions",
"pre-commit-ci",
"copilot-swe-agent",
}
prs_query = """
GITHUB_GRAPHQL_URL = "https://api.github.com/graphql"
GET_PRS_QUERY = """
query Q($after: String) {
repository(name: "django-components", owner: "EmilStenstrom") {
pullRequests(first: 100, after: $after) {
@ -96,7 +107,7 @@ def get_graphql_response(
headers = {"Authorization": f"token {settings.github_token.get_secret_value()}"}
variables = {"after": after}
response = httpx.post(
github_graphql_url,
GITHUB_GRAPHQL_URL,
headers=headers,
timeout=settings.httpx_timeout,
json={"query": query, "variables": variables, "operationName": "Q"},
@ -116,7 +127,7 @@ def get_graphql_response(
def get_graphql_pr_edges(*, settings: Settings, after: Optional[str] = None) -> List[PullRequestEdge]:
"""Fetch pull request edges from GitHub GraphQL API."""
data = get_graphql_response(settings=settings, query=prs_query, after=after)
data = get_graphql_response(settings=settings, query=GET_PRS_QUERY, after=after)
graphql_response = PRsResponse.model_validate(data)
return graphql_response.data.repository.pullRequests.edges
@ -168,22 +179,13 @@ def main() -> None:
g = Github(settings.github_token.get_secret_value())
repo = g.get_repo(settings.github_repository)
contributors_data, users = get_contributors(settings=settings)
maintainers_logins = {
"EmilStenstrom",
"JuroOravec",
}
bot_logins = {
"dependabot",
"github-actions",
"pre-commit-ci",
}
skip_users = maintainers_logins | bot_logins
skip_users = MAINTAINER_USERS | BOT_USERS
maintainers = []
for login in maintainers_logins:
user = users[login]
for username in MAINTAINER_USERS:
user = users[username]
maintainers.append(
{
"login": login,
"login": username,
"avatarUrl": user.avatarUrl,
"url": user.url,
}