|
| 1 | +name: Quarterly recipe maintenance tasks |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "8 0 1 */3 *" |
| 6 | + |
| 7 | +jobs: |
| 8 | + job: |
| 9 | + runs-on: ubuntu-22.04 |
| 10 | + steps: |
| 11 | + - name: Create periodic recipe maintenance issue |
| 12 | + shell: python |
| 13 | + run: | |
| 14 | + import datetime |
| 15 | + import math |
| 16 | + import os |
| 17 | + import re |
| 18 | + import sys |
| 19 | +
|
| 20 | + import requests |
| 21 | +
|
| 22 | + quarter = math.ceil(datetime.date.today().month/3.) |
| 23 | +
|
| 24 | + payload = { |
| 25 | + "title": f"Q{quarter} Recipes Maintenance", |
| 26 | + "body": os.getenv("ISSUE_BODY"), |
| 27 | + "labels": re.sub(r"\s", "", os.getenv("LABELS", "")).split(",") or None, |
| 28 | + "assignees": re.sub(r"\s", "", os.getenv("ASSIGNEES", "")).split(",") or None, |
| 29 | + } |
| 30 | + api_url = f"https://api.github.com/repos/{os.getenv('REPO')}/issues" |
| 31 | + url = f"https://github.com/{os.getenv('REPO')}/issues" |
| 32 | + headers = { |
| 33 | + "Accept": "application/vnd.github.v3+json", |
| 34 | + "Authorization": f"token {os.getenv('ACCESS_TOKEN')}", |
| 35 | + } |
| 36 | + resp = requests.get(api_url, headers=headers) |
| 37 | + if resp.status_code != 200: |
| 38 | + print(f"❌ Couldn't retrieve issues for {url} using {api_url}.") |
| 39 | + print(f"HTTP {resp.status_code} {resp.reason} - {resp.text}") |
| 40 | + print("Check your `ACCESS_TOKEN` secret.") |
| 41 | + sys.exit(1) |
| 42 | + resp = requests.post(api_url, headers=headers, json=payload) |
| 43 | + if resp.status_code != 201: |
| 44 | + print(f"❌ Couldn't create issue for {url}") |
| 45 | + print(f"HTTP {resp.status_code} {resp.reason} - {resp.text}") |
| 46 | + sys.exit(1) |
| 47 | + print(f"✅ Issue successfully created at {url}/{resp.json().get('number')}") |
| 48 | + sys.exit(0) |
| 49 | + env: |
| 50 | + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
| 51 | + REPO: kiwix/k8s |
| 52 | + LABELS: recovery |
| 53 | + ASSIGNEES: benoit74 |
| 54 | + ISSUE_BODY: | |
| 55 | + |
| 56 | + In order to maintain Zimfarm recipes up-to-date, some manual actions are needed. |
| 57 | + |
| 58 | + This ticket requests the assignees to perform following tasks. |
| 59 | + |
| 60 | + ### TED |
| 61 | + |
| 62 | + - [ ] Update (add / delete) the list of TED recipes per topic, including necessary ZIM deletion requests |
| 63 | + - [ ] Update the list of topics in https://farm.openzim.org/recipes/ted_topic_all (until https://github.com/openzim/ted/issues/213 is solved) |
| 64 | + |
| 65 | + See https://github.com/openzim/zimfarm/blob/main/dispatcher/backend/maint-scripts/create_ted_topics_recipes.py (which is not yet handling topic deletions, not seen in the wild) |
| 66 | + |
| 67 | + **Note**: this is an *automatic reminder* intended for the assignee(s). |
| 68 | + |
0 commit comments