Skip to content

Commit

Permalink
🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
itchakhun committed Mar 30, 2020
0 parents commit 49f1f43
Show file tree
Hide file tree
Showing 72 changed files with 7,803 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

.vscode

node_modules
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
34 changes: 34 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const axios = require('axios')

const BLUE = 3447003;
const RED = 15158332;
const GREEN = 3066993;

module.exports.subscribeDiscord = function(event, context) {
const build = eventToBuild(event.data)
const status = ['WORKING', 'SUCCESS', 'FAILURE', 'INTERNAL_ERROR', 'TIMEOUT']

if (!status.includes(build.status)) return;

const buildStatus = build.status
const substitutions = build.substitutions
const branch = substitutions.BRANCH_NAME
const repo = substitutions.REPO_NAME
const commit = substitutions.COMMIT_SHA
const commitUrl = `https://github.com/radiuszon/${repo}/commit/${commit}`

axios.post(process.env.DISCORD_WEBHOOK_URL, {
embeds: [{
title: `${repo}@${branch} is currently ${buildStatus.toLowerCase()}`,
description: `commit ${commit}`,
color: getColor(buildStatus),
url: commitUrl
}]
})
}

const eventToBuild = (data) => {
return JSON.parse(Buffer.from(data, 'base64').toString())
}

const getColor = statusIndex => ({SUCCESS: GREEN, WORKING: BLUE}[statusIndex] || RED)
413 changes: 413 additions & 0 deletions node_modules/axios/CHANGELOG.md

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions node_modules/axios/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 49f1f43

Please sign in to comment.