lazily loading the matrix secrets

- fixes the nightly job failing due to missing secrets
This commit is contained in:
Adam Brown 2022-09-01 22:02:43 +01:00
parent cbad71b015
commit 2b26b55557
1 changed files with 14 additions and 9 deletions

View File

@ -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 <a href="${releaseResult.data.url}">${releaseResult.data.tag_name}</a>`,
"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 <a href="${release.url}">${release.tag_name}</a>`,
"msgtype": "m.text"
}
await client.sendEvent(config.matrixRoomId, "m.room.message", content, "")
}