Skip to content

Commit b02927e

Browse files
authored
Fix e2e notify script again (#5911)
1 parent d04b608 commit b02927e

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

scripts/ci/notify-test-result.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ async function notifyTestResults() {
3838
}
3939

4040
let message = `E2E Tests ${status}`;
41+
let versionOrTag;
4142

4243
// Add version if it can find it in the workflow_dispatch event data.
4344
if (process.env.GITHUB_EVENT_PATH) {
4445
const wrPayload = require(process.env.GITHUB_EVENT_PATH);
4546
if (wrPayload.inputs && wrPayload.inputs.versionOrTag) {
4647
message += ` for release ${wrPayload.inputs.versionOrTag}.`;
48+
versionOrTag = wrPayload.inputs.versionOrTag;
4749
} else {
4850
console.log(`Couldn't find versionOrTag in event payload.`);
4951
}
@@ -102,13 +104,24 @@ async function notifyTestResults() {
102104

103105
req.on('error', error => reject(error));
104106

105-
req.write(
106-
JSON.stringify({
107-
testStatus,
108-
testUrl: workflowUrl
109-
}),
110-
err => reject(err)
111-
);
107+
const data = {
108+
testStatus,
109+
testUrl: workflowUrl
110+
};
111+
112+
if (versionOrTag) {
113+
// Matches a staging version tag pattern.
114+
const match = versionOrTag.match(/^(\d+.\d+.\d+)-\d+$/);
115+
if (match) {
116+
// Remove suffix from staging version
117+
data.version = match[1];
118+
// Full staging version with tag
119+
data.tag = versionOrTag;
120+
} else {
121+
data.version = versionOrTag;
122+
}
123+
}
124+
req.write(JSON.stringify(data), err => reject(err));
112125
req.end();
113126
});
114127

0 commit comments

Comments
 (0)