aboutsummaryrefslogtreecommitdiffstats
path: root/development
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-03-31 08:20:48 +0800
committerkumavis <aaron@kumavis.me>2018-03-31 08:20:48 +0800
commitbc1a456264266191742db829989be27ee569df34 (patch)
tree85463b6e597cae5375812d62a355332be4a2fa7b /development
parent662b1957f46ec105d60993b2a681cea634f8076c (diff)
downloadtangerine-wallet-browser-bc1a456264266191742db829989be27ee569df34.tar.gz
tangerine-wallet-browser-bc1a456264266191742db829989be27ee569df34.tar.zst
tangerine-wallet-browser-bc1a456264266191742db829989be27ee569df34.zip
ci - build:announce - replace bash qith js because of string escaping nightmare
Diffstat (limited to 'development')
-rwxr-xr-xdevelopment/metamaskbot-build-announce.js52
-rwxr-xr-xdevelopment/metamaskbot-build-announce.sh34
2 files changed, 52 insertions, 34 deletions
diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js
new file mode 100755
index 000000000..e867d797e
--- /dev/null
+++ b/development/metamaskbot-build-announce.js
@@ -0,0 +1,52 @@
+#!/usr/bin/env node
+const request = require('request-promise')
+const { version } = require('../dist/chrome/manifest.json')
+
+const GITHUB_COMMENT_TOKEN = process.env.GITHUB_COMMENT_TOKEN
+console.log('GITHUB_COMMENT_TOKEN', 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}`,
+ },
+})
diff --git a/development/metamaskbot-build-announce.sh b/development/metamaskbot-build-announce.sh
deleted file mode 100755
index 52dd24c93..000000000
--- a/development/metamaskbot-build-announce.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"
-SHORT_SHA1=$(echo $CIRCLE_SHA1 | cut -c 1-7)
-BUILD_LINK_BASE="https://$CIRCLE_BUILD_NUM-42009758-gh.circle-artifacts.com/0"
-VERSION=$(node -p 'require("./dist/chrome/manifest.json").version')
-
-MASCARA="$BUILD_LINK_BASE/builds/mascara/home.html"
-CHROME="$BUILD_LINK_BASE/builds/metamask-chrome-$VERSION.zip"
-FIREFOX="$BUILD_LINK_BASE/builds/metamask-firefox-$VERSION.zip"
-EDGE="$BUILD_LINK_BASE/builds/metamask-edge-$VERSION.zip"
-OPERA="$BUILD_LINK_BASE/builds/metamask-opera-$VERSION.zip"
-WALKTHROUGH="$BUILD_LINK_BASE/test-artifacts/screens/walkthrough%20%28en%29.gif"
-
-read -d '' COMMENT_BODY <<EOF
-<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>
-EOF
-
-JSON_PAYLOAD="{\"body\":\"$COMMENT_BODY\"}"
-POST_COMMENT_URI="https://api.github.com/repos/metamask/metamask-extension/issues/$CIRCLE_PR_NUMBER/comments"
-echo "Announcement:"
-echo "$COMMENT_BODY"
-echo "Posting to $POST_COMMENT_URI"
-curl -d "$JSON_PAYLOAD" -H "Authorization: token $GITHUB_COMMENT_TOKEN" $POST_COMMENT_URI