-
Notifications
You must be signed in to change notification settings - Fork 37
Notify internal slack on new releases #1357
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
Conversation
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.
Pull Request Overview
This PR adds Slack notification functionality to the existing GitHub Actions release workflow to notify an internal Slack channel whenever a new release is published.
- Adds environment specification to the app job for proper release environment handling
- Introduces a new
notify-slack
job that fetches release information and sends a formatted notification to Slack - Implements changelog truncation logic to handle long release notes within Slack message limits
uses: 8398a7/action-slack@v3 | ||
with: | ||
status: custom | ||
custom_payload: | |
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 action 8398a7/action-slack@v3 is using an older version that may have security vulnerabilities. Consider updating to a more recent version or using the official Slack GitHub Action for better security and maintenance.
uses: 8398a7/action-slack@v3 | |
with: | |
status: custom | |
custom_payload: | | |
uses: slackapi/slack-github-action@v1 | |
with: | |
payload: | |
Copilot uses AI. Check for mistakes.
echo "url=$release_url" >> $GITHUB_OUTPUT | ||
|
||
# Escape changelog for JSON and truncate if too long | ||
changelog_escaped=$(echo "$changelog" | jq -Rs . | sed 's/^"//;s/"$//') |
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 changelog escaping logic using jq and sed is complex and error-prone. Consider using a simpler approach like 'jq -rRs .' to handle the JSON escaping, or use GitHub's built-in string escaping mechanisms.
changelog_escaped=$(echo "$changelog" | jq -Rs . | sed 's/^"//;s/"$//') | |
changelog_escaped=$(echo "$changelog" | jq -rRs .) |
Copilot uses AI. Check for mistakes.
changelog_escaped=$(echo "$changelog" | jq -Rs . | sed 's/^"//;s/"$//') | ||
if [ ${#changelog_escaped} -gt 2000 ]; then | ||
changelog_escaped="${changelog_escaped:0:2000}..." |
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.
[nitpick] The magic number 2000 for changelog truncation should be documented or made configurable. Consider adding a comment explaining why this specific limit was chosen (likely related to Slack message limits).
changelog_escaped=$(echo "$changelog" | jq -Rs . | sed 's/^"//;s/"$//') | |
if [ ${#changelog_escaped} -gt 2000 ]; then | |
changelog_escaped="${changelog_escaped:0:2000}..." | |
# The truncation limit is set to 2000 characters to comply with Slack's message length constraints. | |
TRUNCATION_LIMIT=2000 | |
changelog_escaped=$(echo "$changelog" | jq -Rs . | sed 's/^"//;s/"$//') | |
if [ ${#changelog_escaped} -gt $TRUNCATION_LIMIT ]; then | |
changelog_escaped="${changelog_escaped:0:$TRUNCATION_LIMIT}..." |
Copilot uses AI. Check for mistakes.
No description provided.