Skip to content

Instantly share code, notes, and snippets.

@alicegoldfuss
Created May 27, 2019 21:58
Show Gist options
  • Save alicegoldfuss/d9a4a8cce0b45e3d37060a07aec616dc to your computer and use it in GitHub Desktop.
Save alicegoldfuss/d9a4a8cce0b45e3d37060a07aec616dc to your computer and use it in GitHub Desktop.
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