Skip to content

Commit

Permalink
Fix e2e notify script again (#5911)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored Feb 1, 2022
1 parent d04b608 commit b02927e
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions scripts/ci/notify-test-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ async function notifyTestResults() {
}

let message = `E2E Tests ${status}`;
let versionOrTag;

// Add version if it can find it in the workflow_dispatch event data.
if (process.env.GITHUB_EVENT_PATH) {
const wrPayload = require(process.env.GITHUB_EVENT_PATH);
if (wrPayload.inputs && wrPayload.inputs.versionOrTag) {
message += ` for release ${wrPayload.inputs.versionOrTag}.`;
versionOrTag = wrPayload.inputs.versionOrTag;
} else {
console.log(`Couldn't find versionOrTag in event payload.`);
}
Expand Down Expand Up @@ -102,13 +104,24 @@ async function notifyTestResults() {

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

req.write(
JSON.stringify({
testStatus,
testUrl: workflowUrl
}),
err => reject(err)
);
const data = {
testStatus,
testUrl: workflowUrl
};

if (versionOrTag) {
// Matches a staging version tag pattern.
const match = versionOrTag.match(/^(\d+.\d+.\d+)-\d+$/);
if (match) {
// Remove suffix from staging version
data.version = match[1];
// Full staging version with tag
data.tag = versionOrTag;
} else {
data.version = versionOrTag;
}
}
req.write(JSON.stringify(data), err => reject(err));
req.end();
});

Expand Down

0 comments on commit b02927e

Please sign in to comment.