Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Slack Notification on Successful Build #3055

Merged
merged 20 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ workflows:
# Parallel Build & Deploy Steps
start_release_builds:
before_run:
- setup
- code_setup_cache
steps:
- build-router-start@0:
inputs:
Expand All @@ -180,11 +180,11 @@ workflows:
inputs:
- deploy_path: $BITRISE_DEPLOY_DIR/app-release.apk
title: Bitrise Deploy APK
# - yarn@0:
# inputs:
# - command: build:announce
# title: Accouncing pre-release
# is_always_run: false
- yarn@0:
inputs:
- command: build:announce
title: Accouncing pre-release
is_always_run: false
android_test_release_step:
before_run:
- code_setup
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
"lint-staged": "10.5.4",
"metro": "^0.59.0",
"metro-react-native-babel-preset": "^0.59.0",
"node-fetch": "^2.6.1",
"octonode": "0.9.5",
"patch-package": "^6.2.2",
"prettier": "1.16.4",
Expand Down
36 changes: 6 additions & 30 deletions scripts/metamask-bot-build-announce-bitrise.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
#!/usr/bin/env node
/* eslint-disable import/no-commonjs */
const request = require('request-promise');
const github = require('octonode');
// eslint-disable-next-line import/no-commonjs
const fetch = require('node-fetch');

const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
const ANDROID_APK_LINK = process.env.BITRISE_PUBLIC_INSTALL_PAGE_URL;
const GIT_PROJECT_REPONAME = 'metamask-mobile';
const BITRISEIO_GIT_REPOSITORY_OWNER = process.env.BITRISEIO_GIT_REPOSITORY_OWNER;
const SLACK_TOKEN = process.env.MM_SLACK_TOKEN;
const SLACK_SECRET = process.env.MM_SLACK_SECRET;
const SLACK_ROOM = process.env.MM_SLACK_ROOM;
const BITRISE_GIT_COMMIT = process.env.BITRISE_GIT_COMMIT;

const BITRISE_GIT_COMMIT_MESSAGE = process.env.BITRISE_GIT_MESSAGE;
start().catch(console.error);

async function getPRInfo() {
const client = github.client(GITHUB_TOKEN);
try {
const REPO = client.repo(`${BITRISEIO_GIT_REPOSITORY_OWNER}/${GIT_PROJECT_REPONAME}`);
const response = await REPO.prsAsync({ state: 'closed' });
const PR = response[0].find(obj => obj.merge_commit_sha === BITRISE_GIT_COMMIT);

if (PR) {
return { title: PR.title, number: PR.number, url: PR.html_url };
}
} catch (e) {
return {};
}
}

async function start() {
const PR_INFO = await getPRInfo();
const content = {
text:
PR_INFO !== {}
? `NEW BUILDS AVAILABLE! Including <${PR_INFO.url}|#${PR_INFO.number} - ${PR_INFO.title}>`
: `NEW BUILDS AVAILABLE!`,
text: `NEW BUILDS AVAILABLE! Commit <https://github.com/MetaMask/metamask-mobile/commit/${BITRISE_GIT_COMMIT}|#${BITRISE_GIT_COMMIT_MESSAGE}>`,
attachments: [
{
title_link: 'itms-beta://beta.itunes.apple.com/v1/app/1438144202',
Expand All @@ -57,9 +34,8 @@ async function start() {
const JSON_PAYLOAD = JSON.stringify(content);
const SLACK_API_URI = `https://hooks.slack.com/services/${SLACK_TOKEN}/${SLACK_SECRET}/${SLACK_ROOM}`;

await request({
method: 'POST',
uri: SLACK_API_URI,
await fetch(SLACK_API_URI, {
sethkfman marked this conversation as resolved.
Show resolved Hide resolved
method: 'post',
body: JSON_PAYLOAD,
headers: {
'Content-type': 'application/json'
Expand Down