-
Notifications
You must be signed in to change notification settings - Fork 65
feat(ci): add Webex space notification for widgets #675
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
Changes from all commits
2b0d506
4df85dd
e81eae2
8fb13e4
40756aa
5124956
c588310
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 |
|---|---|---|
|
|
@@ -360,6 +360,12 @@ jobs: | |
| needs: [publish-npm, publish-tag] | ||
| runs-on: ubuntu-latest | ||
|
|
||
| outputs: | ||
| pr_number: ${{ steps.get-pr.outputs.pr_number }} | ||
| primary_package: ${{ steps.post-comment.outputs.primary_package }} | ||
| primary_version: ${{ steps.post-comment.outputs.primary_version }} | ||
| changelog_url: ${{ steps.post-comment.outputs.changelog_url }} | ||
|
|
||
| steps: | ||
| - name: Get PR Number | ||
| id: get-pr | ||
|
|
@@ -385,6 +391,7 @@ jobs: | |
| core.setOutput('pr_number', ''); | ||
|
|
||
| - name: Post Release Comment on PR | ||
| id: post-comment | ||
| if: steps.get-pr.outputs.pr_number != '' | ||
|
Comment on lines
+394
to
395
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.
The Useful? React with 👍 / 👎. |
||
| uses: actions/github-script@v7 | ||
| with: | ||
|
|
@@ -412,11 +419,14 @@ jobs: | |
| const aggregators = ['@webex/cc-widgets', '@webex/widgets']; | ||
|
|
||
| let commentBody; | ||
| let primaryPackage = ''; | ||
| let primaryVersion = ''; | ||
| let changelogUrl = ''; | ||
|
|
||
| if (hasPackages) { | ||
| const primaryPackage = aggregators.find(p => packageVersions[p]) | ||
| primaryPackage = aggregators.find(p => packageVersions[p]) | ||
| || packageEntries[0][0]; | ||
| const primaryVersion = packageVersions[primaryPackage]; | ||
| primaryVersion = packageVersions[primaryPackage]; | ||
| const stableVersion = primaryVersion | ||
| .replace(/-next\..*/, '') | ||
| .replace(/-[a-z]*\..*/, ''); | ||
|
|
@@ -432,12 +442,13 @@ jobs: | |
| console.log(`Could not read docs/CNAME, using default changelog host: ${e.message}`); | ||
| } | ||
|
|
||
| const changelogUrl = new URL(`https://${cname}/changelog/`); | ||
| const changelogUrlObj = new URL(`https://${cname}/changelog/`); | ||
| if (stableVersion) { | ||
| changelogUrl.searchParams.set('stable_version', stableVersion); | ||
| changelogUrlObj.searchParams.set('stable_version', stableVersion); | ||
| } | ||
| changelogUrl.searchParams.set('package', primaryPackage); | ||
| changelogUrl.searchParams.set('version', primaryVersion); | ||
| changelogUrlObj.searchParams.set('package', primaryPackage); | ||
| changelogUrlObj.searchParams.set('version', primaryVersion); | ||
| changelogUrl = changelogUrlObj.toString(); | ||
|
|
||
| const tagLinkParts = Object.entries(taggablePackages) | ||
| .filter(([pkg]) => packageVersions[pkg]) | ||
|
|
@@ -526,3 +537,70 @@ jobs: | |
| } catch (error) { | ||
| core.warning(`Failed to comment on PR #${prNumber}: ${error.message}`); | ||
| } | ||
|
|
||
| // Set outputs for downstream jobs | ||
| core.setOutput('primary_package', primaryPackage); | ||
| core.setOutput('primary_version', primaryVersion); | ||
| core.setOutput('changelog_url', changelogUrl); | ||
|
Comment on lines
+541
to
+544
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.
This step now feeds downstream notification data via Useful? React with 👍 / 👎. |
||
|
|
||
| notify-webex-space: | ||
| name: Send Webex Space Notification | ||
| needs: [publish-tag, publish-npm, comment-on-pr] | ||
|
Contributor
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. Duplicate Webex notifications on workflow re-runs There is no idempotency key; re-running a successful Deploy CD can post the same Webex message again. If that is undesirable, document it as accepted behavior or add a guard (for example only when
Contributor
Author
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. @akulakum I have addressed this one 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.
The notification job does not depend on Useful? React with 👍 / 👎. |
||
| runs-on: ubuntu-latest | ||
|
Contributor
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. Consider least-privilege If this job only posts to Webex via
Contributor
Author
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. The job currently only posts to Webex via curl and doesn't need write permissions. |
||
| if: always() && github.run_attempt == 1 | ||
|
Comment on lines
+548
to
+550
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.
Useful? React with 👍 / 👎. |
||
|
|
||
| steps: | ||
| - name: Post Webex Space Message | ||
| env: | ||
| WEBEX_BOT_TOKEN: ${{ secrets.WEBEX_BOT_TOKEN }} | ||
| WEBEX_ROOM_ID: ${{ secrets.WEBEX_ROOM_ID }} | ||
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | ||
| run: | | ||
| PACKAGE="${{ needs.comment-on-pr.outputs.primary_package }}" | ||
| VERSION="${{ needs.comment-on-pr.outputs.primary_version }}" | ||
| PR_NUMBER="${{ needs.comment-on-pr.outputs.pr_number }}" | ||
| CHANGELOG_URL="${{ needs.comment-on-pr.outputs.changelog_url }}" | ||
|
|
||
| if [ -n "${PR_NUMBER}" ]; then | ||
| PR_LINK="https://github.com/${{ github.repository }}/pull/${PR_NUMBER}" | ||
| else | ||
| PR_LINK="" | ||
| fi | ||
|
|
||
| PR_TITLE=$(echo "${COMMIT_MESSAGE}" | head -n 1) | ||
|
|
||
| # Build message parts as an array | ||
| MESSAGE_PARTS=() | ||
|
|
||
| if [ -n "${VERSION}" ] && [ -n "${PACKAGE}" ]; then | ||
| MESSAGE_PARTS+=("**Version:** ${PACKAGE}@${VERSION}") | ||
| fi | ||
|
|
||
| if [ -n "${PR_LINK}" ]; then | ||
| MESSAGE_PARTS+=("**PR:** [${PR_TITLE}](${PR_LINK})") | ||
| fi | ||
|
|
||
| if [ -n "${CHANGELOG_URL}" ]; then | ||
| MESSAGE_PARTS+=("**Changelog:** ${CHANGELOG_URL}") | ||
| fi | ||
|
|
||
| if [ ${#MESSAGE_PARTS[@]} -eq 0 ]; then | ||
| echo "No version or PR info available. Skipping notification." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Join parts with double newlines and add extra newline for markdown spacing | ||
| MESSAGE=$(printf '%s\n\n' "${MESSAGE_PARTS[@]}" | sed '$ s/\n\n$//') | ||
|
|
||
| echo "Sending message to Webex Space..." | ||
| echo "Message content:" | ||
| echo "${MESSAGE}" | ||
|
Contributor
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. Message content / logging Echoing the full markdown can be useful while iterating, but confirm this matches your logging policy. The “PR title” is derived from the first line of
Contributor
Author
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. The message content logging is intentional for debugging and visibility. |
||
|
|
||
| BODY=$(jq -n --arg room "${WEBEX_ROOM_ID}" --arg md "${MESSAGE}" '{roomId: $room, markdown: $md}') | ||
| curl -sSf \ | ||
|
Contributor
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. Add timeouts to Without
Contributor
Author
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. The curl request doesn't have explicit timeout, but GitHub Actions jobs have built-in timeouts |
||
| -H "Authorization: Bearer ${WEBEX_BOT_TOKEN}" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d "${BODY}" \ | ||
|
Contributor
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. Runner egress to Webex This step requires outbound HTTPS to
Contributor
Author
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. GitHub runners have outbound HTTPS access to webexapis.com configured. |
||
| https://webexapis.com/v1/messages > /dev/null | ||
|
Comment on lines
+600
to
+604
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.
The workflow calls Useful? React with 👍 / 👎.
Comment on lines
+600
to
+604
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.
This step calls Useful? React with 👍 / 👎. |
||
|
|
||
| echo "Message sent successfully!" | ||
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.
These job outputs are sourced only from
steps.post-comment, but that step is skipped when PR lookup fails (get-prcatches errors and sets an empty PR number). In that case npm publish can still succeed, yetprimary_package/primary_version/changelog_urlstay empty and downstream notification loses release details. Compute metadata independently of PR lookup or provide a fallback source.Useful? React with 👍 / 👎.