mirror of
https://github.com/django-components/django-components.git
synced 2025-11-17 05:48:37 +00:00
docs: ignore copilot-swe-agent from contributors and fix discord release message (#1438)
This commit is contained in:
parent
7aeab02d64
commit
28def742ef
2 changed files with 49 additions and 31 deletions
44
.github/workflows/release-discord.yml
vendored
44
.github/workflows/release-discord.yml
vendored
|
|
@ -1,21 +1,37 @@
|
||||||
name: Notify Discord on Release
|
name: Notify Discord on Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
releases:
|
||||||
tags:
|
types: [published]
|
||||||
- '*'
|
|
||||||
|
|
||||||
# Allows you to run this workflow manually from the Actions tab
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# See https://github.com/teneplaysofficial/releasify-action
|
notify:
|
||||||
# and https://dev.to/tene/introducing-releasify-action-announce-github-releases-on-discord-effortlessly-3132
|
|
||||||
discordNotification:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Notify via Releasify
|
- name: Post to Discord (announcements channel)
|
||||||
uses: teneplaysofficial/releasify-action@v1
|
env:
|
||||||
with:
|
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_ANNOUNCEMENTS }}
|
||||||
webhook: ${{ secrets.DISCORD_WEBHOOK_ANNOUNCEMENTS }}
|
run: |
|
||||||
username: "ReleaseBot"
|
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
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,20 @@ from pydantic_settings import BaseSettings
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
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) {
|
query Q($after: String) {
|
||||||
repository(name: "django-components", owner: "EmilStenstrom") {
|
repository(name: "django-components", owner: "EmilStenstrom") {
|
||||||
pullRequests(first: 100, after: $after) {
|
pullRequests(first: 100, after: $after) {
|
||||||
|
|
@ -96,7 +107,7 @@ def get_graphql_response(
|
||||||
headers = {"Authorization": f"token {settings.github_token.get_secret_value()}"}
|
headers = {"Authorization": f"token {settings.github_token.get_secret_value()}"}
|
||||||
variables = {"after": after}
|
variables = {"after": after}
|
||||||
response = httpx.post(
|
response = httpx.post(
|
||||||
github_graphql_url,
|
GITHUB_GRAPHQL_URL,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
timeout=settings.httpx_timeout,
|
timeout=settings.httpx_timeout,
|
||||||
json={"query": query, "variables": variables, "operationName": "Q"},
|
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]:
|
def get_graphql_pr_edges(*, settings: Settings, after: Optional[str] = None) -> List[PullRequestEdge]:
|
||||||
"""Fetch pull request edges from GitHub GraphQL API."""
|
"""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)
|
graphql_response = PRsResponse.model_validate(data)
|
||||||
return graphql_response.data.repository.pullRequests.edges
|
return graphql_response.data.repository.pullRequests.edges
|
||||||
|
|
||||||
|
|
@ -168,22 +179,13 @@ def main() -> None:
|
||||||
g = Github(settings.github_token.get_secret_value())
|
g = Github(settings.github_token.get_secret_value())
|
||||||
repo = g.get_repo(settings.github_repository)
|
repo = g.get_repo(settings.github_repository)
|
||||||
contributors_data, users = get_contributors(settings=settings)
|
contributors_data, users = get_contributors(settings=settings)
|
||||||
maintainers_logins = {
|
skip_users = MAINTAINER_USERS | BOT_USERS
|
||||||
"EmilStenstrom",
|
|
||||||
"JuroOravec",
|
|
||||||
}
|
|
||||||
bot_logins = {
|
|
||||||
"dependabot",
|
|
||||||
"github-actions",
|
|
||||||
"pre-commit-ci",
|
|
||||||
}
|
|
||||||
skip_users = maintainers_logins | bot_logins
|
|
||||||
maintainers = []
|
maintainers = []
|
||||||
for login in maintainers_logins:
|
for username in MAINTAINER_USERS:
|
||||||
user = users[login]
|
user = users[username]
|
||||||
maintainers.append(
|
maintainers.append(
|
||||||
{
|
{
|
||||||
"login": login,
|
"login": username,
|
||||||
"avatarUrl": user.avatarUrl,
|
"avatarUrl": user.avatarUrl,
|
||||||
"url": user.url,
|
"url": user.url,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue