Periodic DRE Issue #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Periodic DRE Issue | |
on: | |
schedule: | |
- cron: "8 0 1 */3 *" | |
jobs: | |
job: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Create periodic DRE issue | |
shell: python | |
run: | | |
import datetime | |
import math | |
import os | |
import re | |
import sys | |
import requests | |
quarter = math.ceil(datetime.date.today().month/3.) | |
payload = { | |
"title": f"Q{quarter} Disaster Recovery Exercise", | |
"body": os.getenv("ISSUE_BODY"), | |
"labels": re.sub(r"\s", "", os.getenv("LABELS", "")).split(",") or None, | |
"assignees": re.sub(r"\s", "", os.getenv("ASSIGNEES", "")).split(",") or None, | |
} | |
api_url = f"https://api.github.com/repos/{os.getenv('REPO')}/issues" | |
url = f"https://github.com/{os.getenv('REPO')}/issues" | |
headers = { | |
"Accept": "application/vnd.github.v3+json", | |
"Authorization": f"token {os.getenv('ACCESS_TOKEN')}", | |
} | |
resp = requests.get(api_url, headers=headers) | |
if resp.status_code != 200: | |
print(f"❌ Couldn't retrieve issues for {url} using {api_url}.") | |
print(f"HTTP {resp.status_code} {resp.reason} - {resp.text}") | |
print("Check your `ACCESS_TOKEN` secret.") | |
sys.exit(1) | |
resp = requests.post(api_url, headers=headers, json=payload) | |
if resp.status_code != 201: | |
print(f"❌ Couldn't create issue for {url}") | |
print(f"HTTP {resp.status_code} {resp.reason} - {resp.text}") | |
sys.exit(1) | |
print(f"✅ Issue successfully created at {url}/{resp.json().get('number')}") | |
sys.exit(0) | |
env: | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
REPO: kiwix/k8s | |
LABELS: recovery | |
ASSIGNEES: rgaudin,kelson42 | |
ISSUE_BODY: | | |
In order to strengthen our infrastructure, we want to: | |
- Document our Disaster Recovery Plan | |
- Simulate a Disaster and recover the service to ensure documentation exists and is up to date | |
This ticket requests the assignees to: | |
- [ ] Pick a Service from [Kiwix](https://github.com/kiwix)/[openZIM](https://github.com/openzim)/[Offspot](https://github.com/offspot) | |
- [ ] Redeploy it completly using its backup, using the documentation or writing it. | |
See [Zimfarm documentation](https://github.com/openzim/zimfarm/wiki/Restore-from-a-backup). | |
**Note**: this is an *automatic reminder* intended for the assignee(s). | |