Weekly Release Script
#!/usr/local/bin/python3 | |
import requests | |
import json | |
from twilio.rest import Client | |
HEADERS = {'Accept': 'application/vnd.github.inertia-preview+json'} | |
GH_TOKEN = "XXX" # Your auth token from https://github.com/settings/tokens | |
TW_SID = "XXX" # Your Account SID from twilio.com/console | |
TW_TOKEN = "XXX" # Your Auth Token from twilio.com/console | |
DONE = "XXX" # Done column id | |
RELEASE = "XXX" # Release column id | |
TW_PHONE = "+111111111" # Your Twilio account phone number | |
PHONE = "+111111111" # Your phone number | |
# Get Done cards | |
try: | |
url = "https://api.github.com/projects/columns/%s/cards?access_token=%s" % (DONE, GH_TOKEN) | |
r = requests.get(url, headers=HEADERS) | |
except requests.exceptions.RequestException as e: | |
print(e) | |
get_data = r.json() | |
# Collect Done card note data into release_string | |
release_string = "" | |
for item in get_data: | |
string = "- " + item["note"] + '\n' | |
release_string += string | |
# create new Release card using release_string | |
try: | |
url = "https://api.github.com/projects/columns/%s/cards?access_token=%s" % (RELEASE, GH_TOKEN) | |
r = requests.post(url, headers=HEADERS, json = {"note" : release_string}) | |
except requests.exceptions.RequestException as e: | |
print(e) | |
# send text message with release_string | |
client = Client(TW_SID, TW_TOKEN) | |
message = client.messages.create( | |
to=PHONE, | |
from_=TW_PHONE, | |
body="Your Weekly Release!🎉\n\n" + release_string) | |
# archive Done cards | |
for item in get_data: | |
card = item["id"] | |
url = "https://api.github.com/projects/columns/cards/%s?access_token=%s" % (card, GH_TOKEN) | |
try: | |
r = requests.patch(url, headers=HEADERS, json = {"archived" : True}) | |
except requests.exceptions.RequestException as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment