-
Notifications
You must be signed in to change notification settings - Fork 3
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
Adds Slack notifications about releases, upgrades to nextmv-py v0.11.1 #77
Changes from 2 commits
a8e2960
e2d6b65
cf3478a
95f368a
4212571
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
from datetime import datetime | ||
|
||
import nextmv | ||
import requests | ||
from boto3 import client as s3Client | ||
from log import log | ||
from manifest import Manifest | ||
|
@@ -20,6 +21,7 @@ def main(): | |
nextmv.Parameter("bucket", str, description="S3 bucket.", required=True), | ||
nextmv.Parameter("folder", str, description="S3 bucket folder.", required=True), | ||
nextmv.Parameter("manifest", str, description="Manifest file.", required=True), | ||
nextmv.Parameter("slack-url", str, description="Slack webhook URL.", default=None), | ||
) | ||
|
||
apps = [ | ||
|
@@ -84,6 +86,14 @@ def main(): | |
workflow_app=workflow_app, | ||
) | ||
|
||
if options.slack_url is not None: | ||
notify_slack( | ||
url=options.slack_url, | ||
app=name, | ||
version=new_app_version, | ||
marketplace_version=new_marketplace_version, | ||
) | ||
|
||
manifest.upload( | ||
client=client, | ||
bucket=options.bucket, | ||
|
@@ -241,5 +251,21 @@ def bump_marketplace_version( | |
return f"v{major}.{minor}.{patch}" | ||
|
||
|
||
def notify_slack(url: str, app: str, version: str, marketplace_version: str): | ||
""" | ||
Notify Slack channel about release. | ||
""" | ||
|
||
response = requests.post( | ||
url, | ||
json={ | ||
"text": f"Release notification - community-apps/{app} {version} / marketplace {marketplace_version}", | ||
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. I think we should either only notify for prod or log the environment that is being released in here. 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. Yeah, totally. I somehow missed the distinction here. The parameter is optional, so, I will simply drop it in the workflow if not targeting prod. 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. Thanks for noticing! 🤗 |
||
}, | ||
) | ||
|
||
if response.status_code != 200: | ||
log(f"Failed to send notification to Slack: {response.text}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
boto3>=1.34.33 | ||
pyyaml>=6.0.1 | ||
ruff>=0.1.7 | ||
requests>=2.26.0 | ||
nextmv==v0.11.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type hint should be None