Skip to content

Commit adc729c

Browse files
fix(ci): use dynamic package detection with yarn package-tools --recursive
Replace hardcoded packages array with dynamic detection using yarn package-tools list --recursive to correctly detect all affected packages including dependents. This ensures webex is detected when sub-packages change. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 154fe1c commit adc729c

File tree

1 file changed

+41
-10
lines changed

1 file changed

+41
-10
lines changed

.github/workflows/pr-comment-bot.yml

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,39 @@ jobs:
6969
echo "📦 Current version: v${VERSION}"
7070
echo "📌 Previous tag: ${PREVIOUS_TAG}"
7171
72-
- name: Get Merged PRs and Packages
72+
- name: Get Changed Packages
73+
id: get-packages
74+
run: |
75+
PREVIOUS_TAG="${{ steps.version-info.outputs.previous_tag }}"
76+
77+
# Get packages with --recursive to include dependent packages (like webex)
78+
# This ensures that if @webex/plugin-meetings changes, webex is also detected
79+
if [ -n "$PREVIOUS_TAG" ]; then
80+
PACKAGES=$(yarn package-tools list --recursive --since "$PREVIOUS_TAG" 2>/dev/null || echo "webex")
81+
else
82+
PACKAGES=$(yarn package-tools list --recursive --since origin/next 2>/dev/null || echo "webex")
83+
fi
84+
85+
echo "📦 Detected packages: ${PACKAGES}"
86+
87+
# Convert comma-separated to JSON array (handle curly braces from output)
88+
PACKAGES_CLEAN=$(echo "$PACKAGES" | tr -d '{}')
89+
PACKAGES_JSON=$(echo "$PACKAGES_CLEAN" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | sed 's/.*/"&"/' | tr '\n' ',' | sed 's/,$//' | sed 's/^/[/' | sed 's/$/]/')
90+
91+
echo "packages=${PACKAGES_JSON}" >> $GITHUB_OUTPUT
92+
93+
# Check if webex is in the packages list
94+
if echo "$PACKAGES" | grep -q "webex"; then
95+
echo "primary_package=webex" >> $GITHUB_OUTPUT
96+
echo "✅ webex detected in packages"
97+
else
98+
# Use first package
99+
PRIMARY=$(echo "$PACKAGES_CLEAN" | tr ',' '\n' | head -1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
100+
echo "primary_package=${PRIMARY}" >> $GITHUB_OUTPUT
101+
echo "📦 Primary package: ${PRIMARY}"
102+
fi
103+
104+
- name: Get Merged PRs
73105
id: get-prs
74106
uses: actions/github-script@v7
75107
with:
@@ -102,7 +134,7 @@ jobs:
102134
}
103135
} catch (error) {
104136
console.log('Error getting commits:', error.message);
105-
return { prs: [], packages: [], commits: [] };
137+
return { prs: [], commits: [] };
106138
}
107139
108140
console.log(`Found ${commits.length} commits`);
@@ -140,17 +172,12 @@ jobs:
140172
prNumbers.add(testPrNumber.trim());
141173
}
142174
143-
// Get list of published packages from the deploy workflow
144-
const packages = ['webex', '@webex/plugin-meetings', '@webex/calling'];
145-
146175
core.setOutput('pr_numbers', JSON.stringify(Array.from(prNumbers)));
147-
core.setOutput('packages', JSON.stringify(packages));
148176
core.setOutput('commits', JSON.stringify(commitData));
149177
core.setOutput('commit_count', commits.length.toString());
150178
151179
return {
152180
prs: Array.from(prNumbers),
153-
packages: packages,
154181
commits: commitData
155182
};
156183
@@ -161,19 +188,23 @@ jobs:
161188
const version = '${{ steps.version-info.outputs.version }}';
162189
const versionNumber = '${{ steps.version-info.outputs.version_number }}';
163190
const prNumbers = JSON.parse('${{ steps.get-prs.outputs.pr_numbers }}');
164-
const packages = JSON.parse('${{ steps.get-prs.outputs.packages }}');
191+
const packages = JSON.parse('${{ steps.get-packages.outputs.packages }}');
192+
const primaryPackage = '${{ steps.get-packages.outputs.primary_package }}' || 'webex';
165193
const commits = JSON.parse('${{ steps.get-prs.outputs.commits }}');
166194
const commitCount = '${{ steps.get-prs.outputs.commit_count }}';
167195
168196
console.log(`Posting comments to ${prNumbers.length} PRs`);
197+
console.log(`📦 Packages detected: ${packages.length}`);
198+
console.log(`📦 Primary package for changelog: ${primaryPackage}`);
169199
170200
if (prNumbers.length === 0) {
171201
console.log('No PRs found to comment on');
172202
return;
173203
}
174204
175-
// Build the changelog URL - only use stable_version to show all commits in that release
176-
const changelogUrl = `https://webex.github.io/webex-js-sdk/changelog/?stable_version=${versionNumber}`;
205+
// Build the changelog URL using the primary package (webex if detected, else first package)
206+
const stableVersion = versionNumber.replace(/-next\..*$/, '');
207+
const changelogUrl = `https://web-sdk.webex.com/changelog/?stable_version=${stableVersion}&package=${primaryPackage}&version=${versionNumber}`;
177208
178209
// Build the package list markdown
179210
const packageList = packages.slice(0, 5).map(p => `\`${p}\``).join(', ');

0 commit comments

Comments
 (0)