This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c08ff57
commit 83c6a3f
Showing
4 changed files
with
180 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,44 @@ | ||
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core = __importStar(require("@actions/core")); | ||
const axios_1 = __importDefault(require("axios")); | ||
const fs_1 = require("fs"); | ||
const snakecase_keys_1 = __importDefault(require("snakecase-keys")); | ||
const camelcase_keys_1 = __importDefault(require("camelcase-keys")); | ||
const DEPLOYS_URL = process.env.VELOCITY_DEPLOYS_URL || "https://velocity.codeclimate.com/deploys"; | ||
const GITHUB_EVENT_PATH = process.env.GITHUB_EVENT_PATH; | ||
const readEvent = () => camelcase_keys_1.default(JSON.parse(fs_1.readFileSync(GITHUB_EVENT_PATH, "utf8"))); | ||
const report = (deploy) => axios_1.default.post(DEPLOYS_URL, snakecase_keys_1.default({ | ||
branch: deploy.branch, | ||
environment: deploy.environment, | ||
revision: deploy.revision, | ||
version: deploy.version, | ||
repositoryUrl: "foo", | ||
token: process.env.VELOCITY_DEPLOYMENT_TOKEN, | ||
})); | ||
const main = () => { | ||
console.log("Hello world"); | ||
try { | ||
const event = readEvent(); | ||
report({ | ||
revision: process.env.GITHUB_SHA, | ||
branch: process.env.GITHUB_REF, | ||
environment: core.getInput("environment") || (event.deployment || {}).environment, | ||
version: core.getInput("version"), | ||
repositoryUrl: event.repository.webUrl, | ||
}); | ||
} | ||
catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
}; | ||
main(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,52 @@ | ||
import * as core from "@actions/core" | ||
import axios, { AxiosResponse } from "axios" | ||
import { readFileSync } from "fs" | ||
import snake from "snakecase-keys" | ||
import camel from "camelcase-keys" | ||
|
||
interface Deploy { | ||
revision: string | ||
branch: string | ||
environment: string | null | ||
version: string | null | ||
repositoryUrl: string | ||
} | ||
|
||
const DEPLOYS_URL: string = | ||
process.env.VELOCITY_DEPLOYS_URL || "https://velocity.codeclimate.com/deploys" | ||
|
||
const GITHUB_EVENT_PATH: string = process.env.GITHUB_EVENT_PATH as string | ||
const readEvent = (): any => | ||
camel(JSON.parse(readFileSync(GITHUB_EVENT_PATH, "utf8"))) | ||
|
||
const report = (deploy: Deploy): Promise<AxiosResponse<any>> => | ||
axios.post( | ||
DEPLOYS_URL, | ||
snake({ | ||
branch: deploy.branch, | ||
environment: deploy.environment, | ||
revision: deploy.revision, | ||
version: deploy.version, | ||
repositoryUrl: "foo", | ||
token: process.env.VELOCITY_DEPLOYMENT_TOKEN, | ||
}) | ||
) | ||
|
||
const main = (): void => { | ||
console.log("Hello world") | ||
try { | ||
const event = readEvent() | ||
|
||
report({ | ||
revision: process.env.GITHUB_SHA as string, | ||
branch: process.env.GITHUB_REF as string, | ||
environment: | ||
core.getInput("environment") || (event.deployment || {}).environment, | ||
version: core.getInput("version"), | ||
repositoryUrl: event.repository.webUrl, | ||
}) | ||
} catch (error) { | ||
core.setFailed(error.message) | ||
} | ||
} | ||
|
||
main() |