diff --git a/.github/workflows/webex-space-notification.yml b/.github/workflows/webex-space-notification.yml new file mode 100644 index 00000000000..e72182ade74 --- /dev/null +++ b/.github/workflows/webex-space-notification.yml @@ -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 }} + 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!"