aboutsummaryrefslogtreecommitdiffstats
path: root/development
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-04-04 03:51:18 +0800
committerkumavis <aaron@kumavis.me>2018-04-04 03:51:18 +0800
commit502a203218066de284eecc7666bfef3ffe486a20 (patch)
treea6c5e2d2f6ff606689a50d28430ac9f6470dc568 /development
parent92dd2b32187c6e4514823612af9259061bc0e4cb (diff)
downloadtangerine-wallet-browser-502a203218066de284eecc7666bfef3ffe486a20.tar
tangerine-wallet-browser-502a203218066de284eecc7666bfef3ffe486a20.tar.gz
tangerine-wallet-browser-502a203218066de284eecc7666bfef3ffe486a20.tar.bz2
tangerine-wallet-browser-502a203218066de284eecc7666bfef3ffe486a20.tar.lz
tangerine-wallet-browser-502a203218066de284eecc7666bfef3ffe486a20.tar.xz
tangerine-wallet-browser-502a203218066de284eecc7666bfef3ffe486a20.tar.zst
tangerine-wallet-browser-502a203218066de284eecc7666bfef3ffe486a20.zip
ci - metamaskbot-announce - gracefully handle missing PR
Diffstat (limited to 'development')
-rwxr-xr-xdevelopment/metamaskbot-build-announce.js105
1 files changed, 58 insertions, 47 deletions
diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js
index d935b30a6..88614ca5c 100755
--- a/development/metamaskbot-build-announce.js
+++ b/development/metamaskbot-build-announce.js
@@ -2,50 +2,61 @@
const request = require('request-promise')
const VERSION = require('../dist/chrome/manifest.json').version
-const GITHUB_COMMENT_TOKEN = process.env.GITHUB_COMMENT_TOKEN
-const CIRCLE_PULL_REQUEST = process.env.CIRCLE_PULL_REQUEST
-console.log('CIRCLE_PULL_REQUEST', CIRCLE_PULL_REQUEST)
-const CIRCLE_SHA1 = process.env.CIRCLE_SHA1
-console.log('CIRCLE_SHA1', CIRCLE_SHA1)
-const CIRCLE_BUILD_NUM = process.env.CIRCLE_BUILD_NUM
-console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM)
-
-const CIRCLE_PR_NUMBER = CIRCLE_PULL_REQUEST.split('/').pop()
-const SHORT_SHA1 = CIRCLE_SHA1.slice(0,7)
-const BUILD_LINK_BASE = `https://${CIRCLE_BUILD_NUM}-42009758-gh.circle-artifacts.com/0`
-
-const MASCARA = `${BUILD_LINK_BASE}/builds/mascara/home.html`
-const CHROME = `${BUILD_LINK_BASE}/builds/metamask-chrome-${VERSION}.zip`
-const FIREFOX = `${BUILD_LINK_BASE}/builds/metamask-firefox-${VERSION}.zip`
-const EDGE = `${BUILD_LINK_BASE}/builds/metamask-edge-${VERSION}.zip`
-const OPERA = `${BUILD_LINK_BASE}/builds/metamask-opera-${VERSION}.zip`
-const WALKTHROUGH = `${BUILD_LINK_BASE}/test-artifacts/screens/walkthrough%20%28en%29.gif`
-
-const commentBody = `
-<details>
- <summary>
- Builds ready [${SHORT_SHA1}]:
- <a href="${MASCARA}">mascara</a>,
- <a href="${CHROME}">chrome</a>,
- <a href="${FIREFOX}">firefox</a>,
- <a href="${EDGE}">edge</a>,
- <a href="${OPERA}">opera</a>
- </summary>
- <image src="${WALKTHROUGH}">
-</details>
-`
-
-const JSON_PAYLOAD = JSON.stringify({ body: commentBody })
-const POST_COMMENT_URI = `https://api.github.com/repos/metamask/metamask-extension/issues/${CIRCLE_PR_NUMBER}/comments`
-console.log(`Announcement:\n${commentBody}`)
-console.log(`Posting to: ${POST_COMMENT_URI}`)
-
-request({
- method: 'POST',
- uri: POST_COMMENT_URI,
- body: JSON_PAYLOAD,
- headers: {
- 'User-Agent': 'metamaskbot',
- 'Authorization': `token ${GITHUB_COMMENT_TOKEN}`,
- },
-})
+start().catch(console.error)
+
+async function start() {
+
+ const GITHUB_COMMENT_TOKEN = process.env.GITHUB_COMMENT_TOKEN
+ const CIRCLE_PULL_REQUEST = process.env.CIRCLE_PULL_REQUEST
+ console.log('CIRCLE_PULL_REQUEST', CIRCLE_PULL_REQUEST)
+ const CIRCLE_SHA1 = process.env.CIRCLE_SHA1
+ console.log('CIRCLE_SHA1', CIRCLE_SHA1)
+ const CIRCLE_BUILD_NUM = process.env.CIRCLE_BUILD_NUM
+ console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM)
+
+ if (!CIRCLE_PULL_REQUEST) {
+ console.warn(`No pull request detected for commit "${CIRCLE_SHA1}"`)
+ return
+ }
+
+ const CIRCLE_PR_NUMBER = CIRCLE_PULL_REQUEST.split('/').pop()
+ const SHORT_SHA1 = CIRCLE_SHA1.slice(0,7)
+ const BUILD_LINK_BASE = `https://${CIRCLE_BUILD_NUM}-42009758-gh.circle-artifacts.com/0`
+
+ const MASCARA = `${BUILD_LINK_BASE}/builds/mascara/home.html`
+ const CHROME = `${BUILD_LINK_BASE}/builds/metamask-chrome-${VERSION}.zip`
+ const FIREFOX = `${BUILD_LINK_BASE}/builds/metamask-firefox-${VERSION}.zip`
+ const EDGE = `${BUILD_LINK_BASE}/builds/metamask-edge-${VERSION}.zip`
+ const OPERA = `${BUILD_LINK_BASE}/builds/metamask-opera-${VERSION}.zip`
+ const WALKTHROUGH = `${BUILD_LINK_BASE}/test-artifacts/screens/walkthrough%20%28en%29.gif`
+
+ const commentBody = `
+ <details>
+ <summary>
+ Builds ready [${SHORT_SHA1}]:
+ <a href="${MASCARA}">mascara</a>,
+ <a href="${CHROME}">chrome</a>,
+ <a href="${FIREFOX}">firefox</a>,
+ <a href="${EDGE}">edge</a>,
+ <a href="${OPERA}">opera</a>
+ </summary>
+ <image src="${WALKTHROUGH}">
+ </details>
+ `
+
+ const JSON_PAYLOAD = JSON.stringify({ body: commentBody })
+ const POST_COMMENT_URI = `https://api.github.com/repos/metamask/metamask-extension/issues/${CIRCLE_PR_NUMBER}/comments`
+ console.log(`Announcement:\n${commentBody}`)
+ console.log(`Posting to: ${POST_COMMENT_URI}`)
+
+ await request({
+ method: 'POST',
+ uri: POST_COMMENT_URI,
+ body: JSON_PAYLOAD,
+ headers: {
+ 'User-Agent': 'metamaskbot',
+ 'Authorization': `token ${GITHUB_COMMENT_TOKEN}`,
+ },
+ })
+
+}