Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Fix authenticated logins for the label PR action (#405)
Madison Swain-Bowdenfa7234b04e39
diff --git a/automations/python/label_pr.py b/automations/python/label_pr.pyindex d3dbf0974..2b08cf201 100644--- a/automations/python/label_pr.py+++ b/automations/python/label_pr.py@@ -94,14 +94,21 @@ def get_authenticated_html(url: str) -> str:browser = mechanize.Browser()browser.set_cookiejar(CookieJar())browser.open("https://github.com/login/")- browser.select_form(nr=0) # focus on the first (and only) form on the page- browser.form["login"] = os.getenv("GH_LOGIN")- browser.form["password"] = os.getenv("GH_PASSWORD")- browser.submit()-- browser.select_form(nr=0) # focus on the first (and only) form on the page- browser.form["otp"] = pyotp.TOTP(os.getenv("GH_2FA_SECRET")).now()- browser.submit()+ try:+ browser.select_form(nr=0) # focus on the first (and only) form on the page+ browser.form["login"] = os.getenv("GH_LOGIN")+ browser.form["password"] = os.getenv("GH_PASSWORD")+ browser.submit()++ browser.select_form(nr=0) # focus on the first (and only) form on the page+ browser.form["app_otp"] = pyotp.TOTP(os.getenv("GH_2FA_SECRET")).now()+ browser.submit()+ except mechanize.ControlNotFoundError as err:+ form_name = err.args[0].replace("no control matching name ", "").strip("'")+ raise ValueError(+ f"Unable to locate form input '{form_name}' on GitHub login page, "+ "perhaps its name has changed?"+ )browser.open(url)return browser.response().read()diff --git a/docs/projects/README.md b/docs/projects/README.mdindex a1a7936a4..70b343766 100644--- a/docs/projects/README.md+++ b/docs/projects/README.md@@ -65,8 +65,8 @@ relevant step of the process is complete.## Providing project updates-At all stages of a project (except for `Not Started` projects), fortnightly public-updates are the best way for Openverse contributors and maintainers to+At all stages of a project (except for `Not Started` projects), fortnightly+public updates are the best way for Openverse contributors and maintainers tounderstand the health of a project. Importantly, these updates allow us toallocate more time or material resources to projects that need them before workstalls completely.