Skip to content
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

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,6 @@ jobs:
--apps "${{ env.APPS }}" \
--bucket "${{ env.BUCKET }}" \
--folder "${{ env.FOLDER }}" \
--manifest "${{ env.MANIFEST }}"
--manifest "${{ env.MANIFEST }}" \
--slack-url "${{ secrets.SLACK_URL_MISSION_CONTROL }}"
working-directory: ./community-apps/.nextmv/release
26 changes: 26 additions & 0 deletions .nextmv/release/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = [
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Copy link
Member

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

"""
Notify Slack channel about release.
"""

response = requests.post(
url,
json={
"text": f"Release notification - community-apps/{app} {version} / marketplace {marketplace_version}",
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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. ☺️

Copy link
Member Author

Choose a reason for hiding this comment

The 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()
1 change: 1 addition & 0 deletions .nextmv/release/requirements.txt
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
Loading