From 2b26b55557b49ee8fa1dec36894701ce496c758f Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 1 Sep 2022 22:02:43 +0100 Subject: [PATCH] lazily loading the matrix secrets - fixes the nightly job failing due to missing secrets --- tools/beta-release/release.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/beta-release/release.js b/tools/beta-release/release.js index 5c7bb67..dfe83c7 100644 --- a/tools/beta-release/release.js +++ b/tools/beta-release/release.js @@ -6,8 +6,6 @@ import request from 'request' import * as url from 'url' matrixcs.request(request) -const matrixAuth = JSON.parse(fs.readFileSync('.secrets/matrix.json')) -const client = matrix.createClient(matrixAuth) const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); const auth = new google.auth.GoogleAuth({ @@ -69,13 +67,8 @@ export const release = async (github, version, applicationId, artifacts, config) console.log("Promoting beta draft release to live...") await promoteDraftToLive(applicationId) - const content = { - "body": `New release`, - "format": "org.matrix.custom.html", - "formatted_body": `New release rolling out ${releaseResult.data.tag_name}`, - "msgtype": "m.text" - } - await client.sendEvent(config.matrixRoomId, "m.room.message", content, "") + console.log("Sending message to room...") + await sendReleaseMessage(releaseResult.data, config) } const startPlayRelease = async (applicationId) => { @@ -205,3 +198,15 @@ const promoteDraftToLive = async (applicationId) => { packageName: applicationId, }).catch((error) => Promise.reject(error.response.data)) } + +const sendReleaseMessage = async (release, config) => { + const matrixAuth = JSON.parse(fs.readFileSync('.secrets/matrix.json')) + const client = matrix.createClient(matrixAuth) + const content = { + "body": `New release`, + "format": "org.matrix.custom.html", + "formatted_body": `New release rolling out ${release.tag_name}`, + "msgtype": "m.text" + } + await client.sendEvent(config.matrixRoomId, "m.room.message", content, "") +} \ No newline at end of file