-
Notifications
You must be signed in to change notification settings - Fork 16
Sending alerts on devex_alerts channel #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
d65434a
b09813f
6d14567
d9747bf
08b3032
f102196
6ca1d22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Alert on PR Changes | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
alert: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install requests | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install requests | ||
- name: Send Slack alert on PR changes | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.DEVEX_ALERTS_SECRET }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
run: | | ||
import requests, os | ||
repo = os.environ.get('GITHUB_REPOSITORY') | ||
pr_number = os.environ.get('PR_NUMBER') | ||
token = os.environ.get('GITHUB_TOKEN') | ||
api_url = f"https://api.github.com/repos/{repo}/pulls/{pr_number}" | ||
headers = {'Authorization': f'token {token}', 'Accept': 'application/vnd.github.v3+json'} | ||
pr_resp = requests.get(api_url, headers=headers) | ||
branch_name = os.environ.get('GITHUB_HEAD_REF', '') | ||
if pr_resp.status_code == 200: | ||
pr_data = pr_resp.json() | ||
pr_title = pr_data.get('title', '') | ||
pr_body = pr_data.get('body', '') | ||
pr_user = pr_data.get('user', {}).get('login', '') | ||
pr_url = pr_data.get('html_url', '') | ||
message = f"PR Alert!\nTitle: {pr_title}\nBranch: {branch_name}\nAuthor: {pr_user}\nURL: {pr_url}\nDescription: {pr_body}" | ||
else: | ||
message = f"PR Alert!\nUnable to fetch PR details.\nStatus Code: {pr_resp.status_code}\nResponse: {pr_resp.text}" | ||
webhook = os.environ['SLACK_WEBHOOK'] | ||
requests.post(webhook, json={"text": message}) | ||
shell: python |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this being used anywhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, It was just an example which I made in the starting to understand about yaml and was trying to understand different different things. It's not needed. Should I just remove this file, if it's okay with you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes remove it please. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Search terms (required). Results are a logical OR of all terms. | ||
terms: couchbase OR couchbasevectorstore | ||
|
||
summary_term: couchbase | ||
|
||
search_in: post | ||
|
||
# Maximum number of results (optional, default 100, max 1000) | ||
max_results: 1000 | ||
|
||
# Exclusion filters (optional). All excluded fields are lists. | ||
excluded_repos: null | ||
|
||
excluded_users: | ||
- /.*bot.*/ | ||
|
||
excluded_orgs: | ||
- couchbase | ||
- Couchbase-Ecosystem | ||
- couchbase-partners | ||
- couchbaselabs | ||
- couchbase-examples | ||
- couchbasecloud | ||
- couchbase-starter-kit | ||
|
||
# Date range filters (optional, format: YYYY-MM-DD) | ||
date_from: '-P1D' | ||
date_to: 'today' | ||
|
||
# Issue-specific filters (only used when search_type is 'issues') | ||
state: null | ||
is_pr: false | ||
labels: null # is a list of labels | ||
date_type: updated |
Uh oh!
There was an error while loading. Please reload this page.