1
0
mirror of https://codeberg.org/fediverse/fep.git synced 2026-08-05 19:55:46 +00:00

Automate creating readme and tracking issue (#460)

Note at @fediverse/FEP-Editors

- Once this is merged please check it does the right thing.
- If you are ok with automating these things, I'll update the description of a facilitators role to just be checking and mergin
- finally, can we rename the codeberg group, I just addressed, to FEP-Facilitators

Final note: I already configured Woodpecker and the repository. This is to ensure that merging this pull request does not lead to a broken CI, second I might forget the steps ...

- [x] Force myself to document the automated process as a FEP

Reviewed-on: https://codeberg.org/fediverse/fep/pulls/460
Reviewed-by: silverpill <silverpill@noreply.codeberg.org>
Co-authored-by: Helge <helge.krueger@gmail.com>
Co-committed-by: Helge <helge.krueger@gmail.com>
This commit is contained in:
Helge
2025-01-20 10:24:00 +00:00
committed by helge
parent c5d44a7cc5
commit 854ef33092
8 changed files with 281 additions and 54 deletions
+2 -50
View File
@@ -1,64 +1,16 @@
#!/usr/bin/env python
from argparse import ArgumentParser
from datetime import date, timedelta
from tools import FepFile
from tools.issue import create_issue
import json
from urllib.request import Request, urlopen
DRAFT_FEP_LABEL = 149758
parser = ArgumentParser("Create tracking issue for FEP")
parser.add_argument("fep", help="slug of the FEP")
args = parser.parse_args()
fep_file = FepFile(args.fep)
if "trackingIssue" in fep_file.parsed_frontmatter:
print("File already has trackingIssue")
exit(1)
title = f"[TRACKING] FEP-{args.fep}: {fep_file.title}"
date_received = date.fromisoformat(fep_file.parsed_frontmatter["dateReceived"])
date1 = date_received.isoformat()
date2 = (date_received + timedelta(days=365)).isoformat()
body = f"""
The [proposal](https://codeberg.org/fediverse/fep/src/branch/main/{fep_file.filename}) has been received. Thank you!
This issue tracks discussions and updates to the proposal during the `DRAFT` period.
Please post links to relevant discussions as comment to this issue.
`dateReceived`: {date1}
If no further actions are taken, the proposal may be set by the facilitators to `WITHDRAWN` on {date2} (in 1 year).
"""
with open("scripts/config.json") as f:
config = json.load(f)
request = Request(
f"https://codeberg.org/api/v1/repos/{config['owner']}/{config['repo']}/issues"
)
request.add_header("Content-Type", "application/json; charset=utf-8")
request_body = json.dumps(
{"title": title, "body": body, "labels": [DRAFT_FEP_LABEL]}
).encode("utf-8")
request.add_header("authorization", f"Bearer {config['token']}")
request.add_header("Content-Length", len(request_body))
request.data = request_body
response = urlopen(request)
create_issue(config['owner'], config['repo'], config['token'], args.fep)
issue_url = json.loads(response.read())["html_url"]
fep_file.frontmatter.append(f"trackingIssue: {issue_url}")
if "discussionsTo" not in fep_file.parsed_frontmatter:
fep_file.frontmatter.append(f"discussionsTo: {issue_url}")
fep_file.write()
print(f"Issue url: {issue_url}")