-
Notifications
You must be signed in to change notification settings - Fork 395
fix(ci): fix changelog link in the Github-bot #4739
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
base: next
Are you sure you want to change the base?
Changes from 1 commit
c1d8573
b4579b3
a9f7677
00ce506
82e7f27
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 |
|---|---|---|
|
|
@@ -284,6 +284,8 @@ jobs: | |
| version: ${{ steps.versionextractor.outputs.version }} | ||
| commit: ${{ steps.lastcommit.outputs.commit }} | ||
| proceed: ${{ steps.skipcondition.outputs.proceed }} | ||
| package_name: ${{ steps.changedpackage.outputs.package_name }} | ||
| package_version: ${{ steps.changedpackage.outputs.package_version }} | ||
|
|
||
| steps: | ||
| - name: Checkout Project | ||
|
|
@@ -318,6 +320,23 @@ jobs: | |
| echo "message=$(git log -1 --oneline --no-decorate)" >> $GITHUB_OUTPUT | ||
| echo "version=v$(yarn package-tools sync --tag ${GITHUB_REF##*/} --packages webex | awk '{print $3}' | tr -d '%')" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Extract changed package version | ||
|
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. |
||
| id: changedpackage | ||
| run: | | ||
| PACKAGES="${{ needs.generate-package-matrix.outputs.node-recursive }}" | ||
| CLEAN=$(echo "$PACKAGES" | tr -d '{}') | ||
| if echo "$CLEAN" | tr ',' '\n' | grep -q "^webex$"; then | ||
| PKG="webex" | ||
| else | ||
| PKG=$(echo "$CLEAN" | tr ',' '\n' | head -1 | tr -d ' ') | ||
|
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 👍 / 👎. |
||
| fi | ||
| if [ -n "$PKG" ]; then | ||
| PKG_VERSION=$(yarn package-tools sync --tag ${GITHUB_REF##*/} --packages $PKG | awk '{print $3}' | tr -d '%') | ||
| echo "package_name=${PKG}" >> $GITHUB_OUTPUT | ||
| echo "package_version=v${PKG_VERSION}" >> $GITHUB_OUTPUT | ||
| echo "📦 Selected package: ${PKG} version: ${PKG_VERSION}" | ||
| fi | ||
|
|
||
| - name: Conditions to skip tag publish | ||
| id: skipcondition | ||
| run: | | ||
|
|
@@ -365,3 +384,92 @@ jobs: | |
| else | ||
| git push origin ${{ steps.versionextractor.outputs.version }} | ||
| fi | ||
|
|
||
| comment-on-prs: | ||
|
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. If we have everything we need to comment on PRs in deploy.yml now, why do we need pr-comment-bot.yml?
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.
@mkesavan13 You're right, we don't need it anymore. I'll delete pr-comment-bot.yml since the logic has moved into the Deploy CD pipeline. |
||
| name: Comment on Merged PR | ||
| needs: [publish-tag, generate-package-matrix] | ||
| runs-on: ubuntu-latest | ||
| if: ${{ needs.generate-package-matrix.outputs.node-recursive != '' }} | ||
|
|
||
| steps: | ||
| - name: Checkout Project | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Get Pull Request Number | ||
| id: pr | ||
| run: echo "pull_request_number=$(gh pr view --json number -q .number || echo "")" >> $GITHUB_OUTPUT | ||
|
||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Post Comment on PR | ||
| if: ${{ steps.pr.outputs.pull_request_number != '' }} | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| INPUT_VERSION: ${{ needs.publish-tag.outputs.package_version }} | ||
| INPUT_PACKAGES: ${{ needs.generate-package-matrix.outputs.node-recursive }} | ||
| INPUT_PR_NUMBER: ${{ steps.pr.outputs.pull_request_number }} | ||
| INPUT_PACKAGE_NAME: ${{ needs.publish-tag.outputs.package_name }} | ||
| with: | ||
| script: | | ||
| const version = process.env.INPUT_VERSION || ''; | ||
|
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. This is not how we use the env variables in actions. please refer to 'GIT_AUTHOR_NAME' in this file to understand the usage |
||
| const versionNumber = version.replace(/^v/, ''); | ||
| const prNumber = parseInt(process.env.INPUT_PR_NUMBER); | ||
|
|
||
| if (!prNumber) { | ||
| console.log('No PR number found, skipping'); | ||
| return; | ||
| } | ||
|
|
||
| console.log(`Posting comment on PR #${prNumber} for version ${version}`); | ||
|
|
||
| const existingComments = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber | ||
| }); | ||
|
Comment on lines
+517
to
+521
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 duplicate-check only inspects the single page returned by Useful? React with 👍 / 👎.
Comment on lines
+517
to
+521
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 script performs Useful? React with 👍 / 👎. |
||
|
|
||
| const alreadyCommented = existingComments.data.some(c => | ||
| c.user.type === 'Bot' && | ||
| c.body.includes('Your changes are now available') && | ||
| c.body.includes(version) | ||
| ); | ||
|
|
||
| if (alreadyCommented) { | ||
| console.log(`Already commented on PR #${prNumber} for ${version}`); | ||
| return; | ||
| } | ||
|
Comment on lines
+529
to
+532
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. Why do we need this step?
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. @mkesavan13 This is a safety check to prevent duplicate comments.
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. Is there a scenario where duplicate commenting is expected? |
||
|
|
||
| const packagesRaw = process.env.INPUT_PACKAGES || ''; | ||
| const packages = packagesRaw | ||
| .replace(/[{}]/g, '') | ||
| .split(',') | ||
|
Comment on lines
+535
to
+537
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 👍 / 👎. |
||
| .map(p => p.trim()) | ||
| .filter(Boolean); | ||
|
|
||
| const primaryPackage = process.env.INPUT_PACKAGE_NAME || 'webex'; | ||
| const packageList = packages.slice(0, 5).map(p => `\`${p}\``).join(', '); | ||
| const morePackages = packages.length > 5 ? ` and ${packages.length - 5} more` : ''; | ||
|
|
||
| const stableVersion = versionNumber.replace(/-next\..*$/, ''); | ||
| const changelogUrl = `https://web-sdk.webex.com/changelog/?stable_version=${stableVersion}&package=${primaryPackage}&version=${versionNumber}`; | ||
|
Comment on lines
+545
to
+546
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. How does this fix the problem we had of choosing packages[0] while version number was different?
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. I've updated the approach. Instead of hardcoding --packages webex for the version, I added a new changedpackage step in publish-tag that first picks the package (prefers webex if it's in the changed list, otherwise uses the first changed package), then fetches that same package's version from NPM. Both package_name and package_version are derived from the same variable ($PKG), so the version always corresponds to the selected package. This eliminates the mismatch we had before where the version came from webex but the package could be something else. |
||
|
|
||
| const commentBody = [ | ||
| '## 🎉 Your changes are now available!', | ||
| '', | ||
| `**Released in:** [\`${version}\`](https://github.com/${context.repo.owner}/${context.repo.repo}/releases/tag/${version})`, | ||
| `**Packages updated:** ${packageList}${morePackages}`, | ||
| '', | ||
| `📖 **[View full changelog →](${changelogUrl})**`, | ||
| '', | ||
| '---', | ||
| `<sub>🤖 This is an automated message.</sub>` | ||
| ].join('\n'); | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| body: commentBody | ||
| }); | ||
|
|
||
| console.log(`✅ Commented on PR #${prNumber}`); | ||
|
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. We can remove some of the console.logs. |
||
This file was deleted.

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.