Skip to content
This repository was archived by the owner on Mar 1, 2022. It is now read-only.

Commit 4295f13

Browse files
Prepare action
- Check in dependencies - Update workflow for testing purposes - Bug fixes - Add LICENSE and README
1 parent 0cce4e4 commit 4295f13

File tree

145 files changed

+11827
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+11827
-89
lines changed

.github/workflows/workflow.yml

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
on: push
22

3-
43
jobs:
54
build:
6-
name: Build workflow
5+
name: Build stage
6+
runs-on: ubuntu-latest
77

88
steps:
9-
send_velocity_deployment:
10-
- uses: ./../../
11-
- name: Send Velocity deployment
9+
- uses: actions/checkout@master
10+
11+
- name: Run `npm build:production`
12+
run: npm run-script build:production
13+
14+
report:
15+
name: Report stage
16+
runs-on: ubuntu-latest
17+
needs: build
1218

19+
steps:
20+
- uses: actions/checkout@master
21+
22+
- name: Send Velocity deployment
23+
uses: ./
24+
with:
25+
token: ${{ secrets.VELOCITY_DEPLOYMENT_TOKEN }}

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ bower_components
3838
build/Release
3939

4040
# Dependency directories
41-
node_modules/
41+
# Note: As of now, GitHub requires that actions check in the entire dependency
42+
# tree.
43+
# node_modules/
4244
jspm_packages/
4345

4446
# TypeScript v1 declaration files

LICENSE

+661
Large diffs are not rendered by default.

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Velocity deployment reporter
2+
3+
This is a simple GitHub action that will report deployments to [Velocity](https://codeclimate.com/velocity)
4+
5+
### Usage
6+
7+
In your workflow, define a step which refers to the action:
8+
9+
```yml
10+
steps:
11+
# ...
12+
- name: Send Velocity deployment
13+
uses: codeclimate/velocity-deploy-action@master
14+
with:
15+
token: ${{ secrets.VELOCITY_DEPLOYMENT_TOKEN }}
16+
version: ${{ outputs.version }}
17+
environment: ${{ outputs.environment }}
18+
```
19+
20+
There are two possible inputs:
21+
22+
- `token`: (string, required): The Velocity deployment token, which you can find on Velocity's settings. This should be provided as a secret, which you can add by visiting the GitHub repository's settings page.
23+
- `version`: (string) The version tag for the deploy (i.e. `b123`). If this action is triggered on a `deploy` event, it will also try to infer the environment from the event. Please note that the version must be unique for each deployment for the same repository and environment. In other words, if you already deployed a v1.0 for https://github.com/user/project in production, the next deploy for the same repository and environment must have a different version, or no version.
24+
- `environment`: (string) The environment of the deploy (i.e. `production`).
25+
26+
### Copyright
27+
28+
See [LICENSE](LICENSE.md)

action.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ name: Velocity deploy action
22
description: A GitHub Action for sending deployment information to Velocity.
33
author: Code Climate
44
inputs:
5-
myInput:
6-
description: 'Input to use'
7-
default: 'world'
5+
token:
6+
description: "Your Velocity deployment token"
7+
required: true
8+
version:
9+
description: "The version tag for the deploy (i.e. `b123`)"
10+
environment:
11+
description: "The environment of the deploy (i.e. `production`)"
812
runs:
913
using: "node12"
1014
main: "lib/main.js"

lib/main.js

+34-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
return new (P || (P = Promise))(function (resolve, reject) {
4+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7+
step((generator = generator.apply(thisArg, _arguments || [])).next());
8+
});
9+
};
210
var __importStar = (this && this.__importStar) || function (mod) {
311
if (mod && mod.__esModule) return mod;
412
var result = {};
@@ -17,21 +25,34 @@ const snakecase_keys_1 = __importDefault(require("snakecase-keys"));
1725
const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
1826
const DEPLOYS_URL = process.env.VELOCITY_DEPLOYS_URL || "https://velocity.codeclimate.com/deploys";
1927
const GITHUB_EVENT_PATH = process.env.GITHUB_EVENT_PATH;
20-
const readEvent = () => camelcase_keys_1.default(JSON.parse(fs_1.readFileSync(GITHUB_EVENT_PATH, "utf8")));
21-
const report = (deploy) => axios_1.default.post(DEPLOYS_URL, snakecase_keys_1.default(Object.assign({}, deploy, { token: process.env.VELOCITY_DEPLOYMENT_TOKEN })));
22-
const main = () => {
28+
const readEvent = () => camelcase_keys_1.default(JSON.parse(fs_1.readFileSync(GITHUB_EVENT_PATH, "utf8")), { deep: true });
29+
const report = (deploy) => axios_1.default.post(DEPLOYS_URL, snakecase_keys_1.default(Object.assign({}, deploy, { token: core.getInput("token") })), {
30+
headers: {
31+
Accept: "application/json",
32+
},
33+
});
34+
const run = () => __awaiter(this, void 0, void 0, function* () {
35+
const event = readEvent();
36+
const deploy = {
37+
revision: process.env.GITHUB_SHA,
38+
branch: process.env.GITHUB_REF.replace("refs/heads", ""),
39+
environment: core.getInput("environment") ||
40+
(event.deployment || {}).environment ||
41+
null,
42+
version: core.getInput("version") || null,
43+
repositoryUrl: event.repository.url,
44+
};
45+
core.debug("Reporting deploy to Velocity...");
46+
core.debug(`revision: ${deploy.revision}`);
47+
core.debug(`branch: ${deploy.branch}`);
48+
core.debug(`environment: ${deploy.environment}`);
49+
core.debug(`version: ${deploy.version}`);
2350
try {
24-
const event = readEvent();
25-
report({
26-
revision: process.env.GITHUB_SHA,
27-
branch: process.env.GITHUB_REF,
28-
environment: core.getInput("environment") || (event.deployment || {}).environment,
29-
version: core.getInput("version"),
30-
repositoryUrl: event.repository.webUrl,
31-
});
51+
yield report(deploy);
52+
core.debug("Reported deploy.");
3253
}
3354
catch (error) {
3455
core.setFailed(error.message);
3556
}
36-
};
37-
main();
57+
});
58+
run();

node_modules/@actions/core/README.md

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.d.ts

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js

+66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/core.d.ts

+81
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)