Browse Source

Don't check node version when uploading binary to Slack

master
Leo Lamprecht 8 years ago
parent
commit
1d2b6bc3e1
  1. 38
      scripts/slack.js

38
scripts/slack.js

@ -11,8 +11,6 @@ const branch = process.env.CIRCLE_BRANCH
const apiKey = process.env.SLACK_TOKEN
const channel = process.env.SLACK_CHANNEL
const githubToken = process.env.GITHUB_TOKEN
const currentNodeVersion = process.version
const regex = /^(node|7)\.*/
// Skip if not on a zeit repo
if (!/^zeit\//.test(repo)) {
@ -49,28 +47,20 @@ fetch(`https://api.github.com/repos/${repo}/commits/${commit}`, opts)
authorUrl: res.author.html_url
}))
.then(async res => {
if (regex.test(currentNodeVersion)) {
const message = `:package: Here are the binaries for the branch *${branch}* of *${repo}* (commit <https://github.com/${repo}/commit/${commit}|${commit.substr(0, 7)}> by <${res.authorUrl}|${res.authorName}>):`
const message = `:package: Here are the binaries for the branch *${branch}* of *${repo}* (commit <https://github.com/${repo}/commit/${commit}|${commit.substr(0, 7)}> by <${res.authorUrl}|${res.authorName}>):`
const binaries = [
`${__dirname}/../packed/now-macos`,
`${__dirname}/../packed/now-linux`,
`${__dirname}/../packed/now-win.exe`
]
const binaries = [
`${__dirname}/../packed/now-macos`,
`${__dirname}/../packed/now-linux`,
`${__dirname}/../packed/now-win.exe`
]
try {
await slackup({ apiKey, channel, type: 'message', message })
await slackup({ apiKey, channel, type: 'file', filePath: binaries[0] })
await slackup({ apiKey, channel, type: 'file', filePath: binaries[1] })
await slackup({ apiKey, channel, type: 'file', filePath: binaries[2] })
} catch (err) {
console.log(`Couldn't send messages/files to Slack`, err)
}
} else {
setTimeout(async () => {
const message = `:white_check_mark: Build succeded on Node ${currentNodeVersion} (commit <https://github.com/${repo}/commit/${commit}|${commit.substr(0, 7)}> by <${res.authorUrl}|${res.authorName}>)`
await slackup({ apiKey, channel, type: 'message', message })
}, 10000)
try {
await slackup({ apiKey, channel, type: 'message', message })
await slackup({ apiKey, channel, type: 'file', filePath: binaries[0] })
await slackup({ apiKey, channel, type: 'file', filePath: binaries[1] })
await slackup({ apiKey, channel, type: 'file', filePath: binaries[2] })
} catch (err) {
console.log(`Couldn't send messages/files to Slack`, err)
}
})
.catch(console.error)
}).catch(console.error)

Loading…
Cancel
Save