generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
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
4668480
commit 83b8033
Showing
8 changed files
with
306 additions
and
64 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
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,5 +1,32 @@ | ||
# Node 12 Template Action | ||
# GitHub action to create a card in a Glo Board | ||
|
||
To get started, click the `Use this template` button on this repository [which will create a new repository based on this template](https://github.blog/2019-06-06-generate-new-repositories-with-repository-templates/). | ||
Use this action to create a card on a [Glo Board](https://www.gitkraken.com/glo). | ||
The action requires a board ID, name and a column as inputs. | ||
|
||
For info on how to build your first JavaScript action, see the [toolkit docs folder](https://github.com/actions/toolkit/blob/master/docs/node12-action.md). | ||
## Requirements | ||
The action requires an auth token in the form of a PAT that you can create in your GitKraken account. | ||
See the [Personal Access Tokens](https://support.gitkraken.com/developers/pats/) page on our support site. | ||
|
||
This token should be stored in your GitHub repo secrets (in repo Settings -> Secrets). | ||
|
||
## Inputs | ||
The `boardId` input is the ID of the Glo Board to create the card in. | ||
The `name` input is the name of the card. | ||
The `column` input is the name of a column that already exists in the Glo Board. | ||
The `description` input is the description for the card (optional). | ||
The `assignee` input is the username of a user to assign to the card (optional). | ||
The `label` input is the name of a lable to add to the card (optional). | ||
|
||
## Examples | ||
Add a step in your workflow file to perform this action: | ||
```yaml | ||
steps: | ||
- uses: Axosoft/glo-action-create-card@v1 | ||
with: | ||
authToken: ${{ secrets.GLO-PAT }} | ||
boardId: '1234' | ||
name: 'New card from action' | ||
column: 'New' | ||
label: 'Bug' | ||
id: glo-create | ||
``` |
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,4 +1,3 @@ | ||
describe('TODO - Add a test suite', () => { | ||
it('TODO - Add a test', async () => { | ||
}); | ||
it('TODO - Add a test', async () => {}); | ||
}); |
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,10 +1,18 @@ | ||
name: 'Node 12 Template Action' | ||
description: 'Get started with Node actions' | ||
author: 'GitHub' | ||
inputs: | ||
myInput: | ||
description: 'Input to use' | ||
default: 'world' | ||
name: 'Glo Create Card' | ||
description: 'GitHub action to create a card in a Glo Board' | ||
branding: | ||
color: 'blue' | ||
icon: 'credit-card' | ||
inputs: | ||
authToken: | ||
description: Auth token for user | ||
required: true | ||
cards: | ||
description: Array of { cardId, boardId } objects | ||
required: true | ||
column: | ||
description: Name of column to move cards to | ||
required: true | ||
runs: | ||
using: 'node12' | ||
main: 'lib/main.js' |
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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
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 glo_sdk_1 = __importDefault(require("@axosoft/glo-sdk")); | ||
function run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log('here'); | ||
//required | ||
const authToken = core.getInput('authToken'); | ||
const boardId = core.getInput('boardID'); | ||
const name = core.getInput('name'); | ||
const columnName = core.getInput('column'); | ||
const position = 0; | ||
//optional | ||
const description = core.getInput('description'); | ||
const username = core.getInput('assignee'); | ||
const labelName = core.getInput('label'); | ||
console.log('here1'); | ||
try { | ||
if (!boardId || !name || !columnName || !authToken) { | ||
console.log('here2'); | ||
return; | ||
} | ||
// find the board { id, labels } | ||
const board = yield glo_sdk_1.default(authToken).boards.get(boardId, { | ||
fields: ['columns', 'labels', 'members'] | ||
}); | ||
console.log('here3'); | ||
if (!board) { | ||
core.setFailed(`Board ${boardId} not found`); | ||
return; | ||
} | ||
let cardToCreate = { | ||
name, | ||
position | ||
}; | ||
console.log('here4'); | ||
//set description | ||
if (description) { | ||
cardToCreate.description = { | ||
text: description | ||
}; | ||
} | ||
console.log('here5'); | ||
// find label | ||
if (board.labels) { | ||
const label = board.labels.find(l => l.name === labelName); | ||
if (label) { | ||
cardToCreate.labels = [ | ||
{ | ||
id: label.id, | ||
name: label.name | ||
} | ||
]; | ||
} | ||
} | ||
// find assignee | ||
if (board.members) { | ||
const member = board.members.find(m => m.username === username); | ||
if (member) { | ||
cardToCreate.assignees = [ | ||
{ | ||
id: member.id | ||
} | ||
]; | ||
} | ||
} | ||
// find column | ||
if (board.columns) { | ||
const column = board.columns.find(c => c.name === columnName); | ||
if (column) { | ||
cardToCreate.column_id = column.id; | ||
} | ||
else { | ||
core.setFailed(`Column ${columnName} not found`); | ||
return; | ||
} | ||
} | ||
console.log('here6'); | ||
//create card | ||
yield glo_sdk_1.default(authToken).boards.cards.create(boardId, cardToCreate); | ||
console.log('here7'); | ||
} | ||
catch (error) { | ||
console.log(error); | ||
core.setFailed(error.message); | ||
} | ||
}); | ||
} | ||
run(); |
Oops, something went wrong.