-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into abanuelo/feat-ending-dynamic-scenarios
- Loading branch information
Showing
72 changed files
with
1,846 additions
and
445 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
blank_issues_enabled: true | ||
contact_links: | ||
- name: Questions | ||
url: https://forms.gle/uUhQNuPzQrvvBFJX9 | ||
about: Send your questions via Google Form | ||
url: https://forum.scenic-lang.org/ | ||
about: Post your questions on our community forum |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import argparse | ||
|
||
import requests | ||
from slack_sdk import WebClient | ||
from slack_sdk.errors import SlackApiError | ||
|
||
|
||
def save_users(users_array): | ||
users = {} | ||
for user in users_array: | ||
# NOTE: some apps, slackbots do not have emails to map to | ||
profile = user["profile"] | ||
if "email" in profile.keys(): | ||
user_email = profile["email"] | ||
username = user_email.split("@")[0] | ||
users[username] = user | ||
return users | ||
|
||
|
||
def grab_whos_on_call(OPS_GENIE_API_TOKEN, ROTATION_SCHEDULE_ID): | ||
url = f"https://api.opsgenie.com/v2/schedules/{ROTATION_SCHEDULE_ID}/on-calls" | ||
headers = {"Authorization": f"GenieKey {OPS_GENIE_API_TOKEN}"} | ||
response = requests.get(url, headers=headers) | ||
if response.status_code == 200: | ||
data = response.json() | ||
else: | ||
print(f"Request failed with status code {response.status_code}") | ||
print("Response content:") | ||
print(response.content.decode("utf-8")) | ||
return data["data"]["onCallParticipants"][0]["name"].split("@")[0] | ||
|
||
|
||
def postSlackMessage(client, CHANNEL_ID, OPS_GENIE_API_TOKEN, ROTATION_SCHEDULE_ID): | ||
try: | ||
result = client.users_list() | ||
users = save_users(result["members"]) | ||
on_call = grab_whos_on_call(OPS_GENIE_API_TOKEN, ROTATION_SCHEDULE_ID) | ||
slack_id = users[on_call]["id"] | ||
|
||
result = client.chat_postMessage( | ||
channel=CHANNEL_ID, | ||
text=f"""🛠️Maintenance On-Call: <@{slack_id}>, you will be on-call for the next week. Resources:\n | ||
📖 <https://https://scenic-lang.atlassian.net/l/cp/cnaQtVXY|On Call Best Practices> | ||
🔍 <https://scenic-lang.atlassian.net/l/cp/jR0CifEf|Issue Triage Guide> | ||
📊 <https://scenic-lang.atlassian.net/jira/software/projects/SCENIC/boards/1|Jira Board to monitor active workstreams> | ||
📋 <https://scenic-lang.atlassian.net/jira/software/projects/SCENIC/boards/1/backlog?epics=visible|Jira Backlog to monitor issues that need triaging> | ||
🔧 <https://github.com/BerkeleyLearnVerify/Scenic/issues|Scenic GitHub Issues> | ||
""", | ||
) | ||
except SlackApiError as e: | ||
print(f"SlackAPIError: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description="Script that notifies on-call rotation daily" | ||
) | ||
parser.add_argument("--slack_api_token", required=True, type=str) | ||
parser.add_argument("--ops_genie_api_token", required=True, type=str) | ||
args = parser.parse_args() | ||
|
||
SLACK_API_TOKEN = args.slack_api_token | ||
OPS_GENIE_API_TOKEN = args.ops_genie_api_token | ||
# NOTE: Feel free to grab the relevant channel ID to post the message to but ensure the App is installed within the channel | ||
CHANNEL_ID = "C06N9KJHN2J" | ||
# NOTE: Rotation schedule is grabbed directly from within the OpsGenie site | ||
ROTATION_SCHEDULE_ID = "904cd122-f269-418d-8c29-3e6751716bae" | ||
|
||
client = WebClient(token=SLACK_API_TOKEN) | ||
postSlackMessage(client, CHANNEL_ID, OPS_GENIE_API_TOKEN, ROTATION_SCHEDULE_ID) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: on_call_reminder | ||
|
||
on: | ||
schedule: | ||
- cron: '0 17 * * 3' # Runs every Wednesday at 9am PST (17:00 UTC) | ||
workflow_dispatch: # Allows manual triggering of the workflow | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install requests slack_sdk argparse | ||
- name: Run Python script | ||
env: | ||
SLACK_API_TOKEN: ${{ secrets.SLACK_API_TOKEN }} | ||
OPS_GENIE_API_TOKEN: ${{ secrets.OPS_GENIE_API_TOKEN }} | ||
run: python .github/slack_oncall_reminder.py --slack_api_token $SLACK_API_TOKEN --ops_genie_api_token $OPS_GENIE_API_TOKEN |
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
Oops, something went wrong.