Skip to content
Open
Changes from all 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
96 changes: 96 additions & 0 deletions .github/workflows/webex-space-notification.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Webex Space Release Notification
run-name: ${{ github.actor }} triggered Webex space notification

on:
workflow_dispatch:
workflow_run:
workflows: ["Deploy CD"]
types:
- completed
branches:
- next

jobs:
notify-webex-space:
name: Send Webex Space Notification
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get Version and PR from Tag
id: tag-info
run: |
git fetch --tags
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$VERSION" ]; then
echo "❌ No tags found"
exit 1
fi
TAG_MESSAGE=$(git tag -l --format='%(contents:subject)' "$VERSION")
PR_NUMBER=$(echo "$TAG_MESSAGE" | grep -oE '#[0-9]+' | head -1 | tr -d '#')
echo "📦 Tag: ${VERSION}, PR: #${PR_NUMBER}"

echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT

- name: Get Changelog URL from PR Comment
id: get-changelog
uses: actions/github-script@v7
with:
script: |
const prNumber = '${{ steps.tag-info.outputs.pr_number }}';
if (!prNumber) {
console.log('❌ No PR number, skipping changelog fetch');
core.setOutput('changelog_url', '');
return;
}

const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(prNumber)
});

const botComment = comments.data.find(c =>
c.user.type === 'Bot' &&
c.body.includes('Your changes are now available')
);

if (botComment) {
const match = botComment.body.match(/\[View full changelog[^\]]*\]\(([^)]+)\)/);
const url = match ? match[1] : '';
console.log(`✅ Found changelog URL: ${url}`);
core.setOutput('changelog_url', url);
} else {
console.log('⚠️ No bot comment found on PR');
core.setOutput('changelog_url', '');
}

- name: Post Webex Space Message
env:
WEBEX_BOT_TOKEN: ${{ secrets.WEBEX_BOT_TOKEN }}
WEBEX_ROOM_ID: ${{ secrets.WEBEX_ROOM_ID }}
Comment on lines +77 to +78
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we added these secrets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shreyas281299 Yes I have added that secrets

run: |
VERSION="${{ steps.tag-info.outputs.version }}"
PR_NUMBER="${{ steps.tag-info.outputs.pr_number }}"
CHANGELOG_URL="${{ steps.get-changelog.outputs.changelog_url }}"

PR_LINK="https://github.com/${{ github.repository }}/pull/${PR_NUMBER}"

MESSAGE="**SDK Version:** ${VERSION}\n\n**PR:** ${PR_LINK}\n\n**Changelog:** ${CHANGELOG_URL}"

echo "📨 Sending message to Webex Space..."

curl -sSf \
-H "Authorization: Bearer ${WEBEX_BOT_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"roomId\":\"${WEBEX_ROOM_ID}\",\"markdown\":\"${MESSAGE}\"}" \
https://webexapis.com/v1/messages > /dev/null

echo "✅ Message sent successfully!"
Loading