Skip to content
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
9 changes: 1 addition & 8 deletions .github/workflows/actions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ workflows:
'.github/workflows/mypy.yml':
- 'actions/checkout@v7.0.1'
- 'astral-sh/setup-uv@v10.2.0'
'.github/workflows/new-bugs-announce-notifier.yml':
- 'actions/github-script@v9.0.0'
- 'actions/setup-node@v7.0.0'
'.github/workflows/new-bugs-announce-notifier.yml': []
'.github/workflows/require-pr-label.yml':
- 'mheap/github-action-required-labels@v5.6.0'
'.github/workflows/reusable-check-c-api-docs.yml':
Expand Down Expand Up @@ -94,11 +92,6 @@ dependencies:
commit: 'sha1-3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c'
owner_id: 44036562
repo_id: 192626254
'actions/github-script@v9.0.0':
ref: 'v9.0.0'
commit: 'sha1-3a2844b7e9c422d3c10d287c895573f7108da1b3'
owner_id: 44036562
repo_id: 205262760
'actions/setup-node@v7.0.0':
ref: 'v7.0.0'
commit: 'sha1-820762786026740c76f36085b0efc47a31fe5020'
Expand Down
100 changes: 52 additions & 48 deletions .github/workflows/new-bugs-announce-notifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,64 @@ on:
types:
- opened

permissions:
contents: read
permissions: {}

jobs:
notify-new-bugs-announce:
runs-on: ubuntu-slim
permissions:
issues: read
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/setup-node@v7.0.0
with:
node-version: 20
# TODO: Replace with a committed lockfile and `npm ci`, or drop npm
# and call the Mailgun REST API from the standard library.
- run: npm install mailgun.js form-data # zizmor: ignore[adhoc-packages]
- name: Send notification
uses: actions/github-script@v9.0.0
env:
MAILGUN_API_KEY: ${{ secrets.MAILGUN_PYTHON_ORG_MAILGUN_KEY }}
with:
script: |
const Mailgun = require("mailgun.js");
const formData = require('form-data');
const mailgun = new Mailgun(formData);
const DOMAIN = "mailgun.python.org";
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY});
github.rest.issues.get({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
.then(function(issue) {
const payload = {
author : issue.data.user.login,
issue : issue.data.number,
title : issue.data.title,
url : issue.data.html_url,
labels : issue.data.labels.map(label => { return label.name }).join(", "),
assignee : issue.data.assignees.map(assignee => { return assignee.login }),
// We need to truncate the body size, because the max size for
// the whole payload is 16kb. We want to be safe and assume that
// body can take up to ~8kb of space.
body : (issue.data.body || "").substring(0, 8000)
};
shell: python
run: |
import base64
import json
import os
import urllib.error
import urllib.parse
import urllib.request
const data = {
from: "CPython Issues <github@mailgun.python.org>",
to: "new-bugs-announce@python.org",
subject: `[Issue ${issue.data.number}] ${issue.data.title}`,
template: "new-github-issue",
'o:tracking-clicks': 'no',
'h:X-Mailgun-Variables': JSON.stringify(payload)
};
return mg.messages.create(DOMAIN, data)
})
.then(msg => console.log(msg));
with open(os.environ["GITHUB_EVENT_PATH"], encoding="utf-8") as f:
issue = json.load(f)["issue"]
payload = {
"author": issue["user"]["login"],
"issue": issue["number"],
"title": issue["title"],
"url": issue["html_url"],
"labels": ", ".join(label["name"] for label in issue["labels"]),
"assignee": [assignee["login"] for assignee in issue["assignees"]],
# We need to truncate the body size, because the max size for
# the whole payload is 16 kB. We want to be safe and assume that
# body can take up to ~8 kB of space. Truncate by bytes, not
# characters, so non-ASCII text can't exceed that.
"body": (issue["body"] or "").encode()[:8000].decode(errors="ignore"),
}
data = urllib.parse.urlencode(
{
"from": "CPython Issues <github@mailgun.python.org>",
"to": "new-bugs-announce@python.org",
"subject": f"[Issue {issue['number']}] {issue['title']}",
"template": "new-github-issue",
"o:tracking-clicks": "no",
"h:X-Mailgun-Variables": json.dumps(payload, ensure_ascii=False),
}
).encode()
credentials = b"api:" + os.environ["MAILGUN_API_KEY"].encode()
request = urllib.request.Request(
"https://api.mailgun.net/v3/mailgun.python.org/messages",
data=data,
headers={
"Authorization": "Basic " + base64.b64encode(credentials).decode(),
},
)
try:
with urllib.request.urlopen(request) as response:
print(response.read().decode())
except urllib.error.HTTPError as e:
print(f"Mailgun returned HTTP {e.code}: {e.read().decode()}")
raise SystemExit(1)
6 changes: 0 additions & 6 deletions .github/zizmor.yml

This file was deleted.

Loading