Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
63 changes: 59 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
getCardIdAndBlock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: get card id
id: getCardId
uses: ./extractCardId
Expand All @@ -28,7 +28,7 @@ jobs:
createAndMove:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: create card
id: createCard
uses: ./createCard
Expand Down Expand Up @@ -58,10 +58,19 @@ jobs:
cardId: ${{ steps.createCard.outputs.createdCardId }}
isBlocked: ${{ github.event.client_payload.blockCard.isBlocked }}
blockReason: ${{ github.event.client_payload.blockCard.blockReason }}

- name: add tag
id: addTag
uses: ./addTag
with:
host: ${{ github.event.client_payload.common.host }}
apiToken: ${{ github.event.client_payload.common.apiToken }}
cardId: ${{ steps.createCard.outputs.createdCardId }}
tag: ${{ github.event.client_payload.addTag.tag }}
validateCustomFields:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: validate
id: validate
Expand All @@ -78,6 +87,52 @@ jobs:
with:
host: ${{ github.event.client_payload.common.host }}
apiToken: ${{ github.event.client_payload.common.apiToken }}
cardId: ${{ github.event.client_payload.addComment.cardId }}
cardId: ${{ github.event.client_payload.common.cardId }}
comment: ${{ github.event.client_payload.addComment.comment }}

checkAndAddTag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: check if tag exists
id: hasTag
uses: ./hasTag
with:
host: ${{ github.event.client_payload.common.host }}
apiToken: ${{ github.event.client_payload.common.apiToken }}
cardId: ${{ github.event.client_payload.common.cardId }}
tag: ${{ github.event.client_payload.addTag.tag }}

- name: show current tags
run: "echo tags: ${{ steps.hasTag.outputs.tags }}"

- name: add tag if not exists
if: ${{ steps.hasTag.outputs.hasTag == 'false' }}
uses: ./addTag
with:
host: ${{ github.event.client_payload.common.host }}
apiToken: ${{ github.event.client_payload.common.apiToken }}
cardId: ${{ github.event.client_payload.common.cardId }}
tag: ${{ github.event.client_payload.addTag.tag }}

getCardDataAndTagType:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: get card data
id: getCardData
uses: ./getCardData
with:
host: ${{ github.event.client_payload.common.host }}
apiToken: ${{ github.event.client_payload.common.apiToken }}
cardId: ${{ github.event.client_payload.common.cardId }}

- name: add card type as tag
uses: ./addTag
with:
host: ${{ github.event.client_payload.common.host }}
apiToken: ${{ github.event.client_payload.common.apiToken }}
cardId: ${{ github.event.client_payload.common.cardId }}
tag: ${{ fromJson(steps.getCardData.outputs.cardData).type.title }}
100 changes: 88 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AgilePlace Github Actions
These Github Actions provide an easy way to interact with your AgilePlace account during your build or deployment lifecycle. For more information on using Github Actions in general, see https://docs.github.com/en/actions.

To consume, reference this repository, and the action. All available AgilePlace Actions are in this repository only. For example: `use: leankit/github-actions/blockCard@v1.5`. See specific examples with input parameters below.
To consume, reference this repository, and the action. All available AgilePlace Actions are in this repository only. For example: `use: leankit/github-actions/blockCard@v1.6`. See specific examples with input parameters below.

## Usage Notes

Expand Down Expand Up @@ -72,7 +72,7 @@ Add a comment to a card
#### Example workflow step
```
- name: add comment to card
uses: leankit/github-actions/addComment@v1.5
uses: leankit/github-actions/addComment@v1.6
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
Expand All @@ -82,6 +82,30 @@ Add a comment to a card
#### Outputs
* error; error message if failed

-----------
### Add Tag
Add a tag to a card
#### Input Params
|name|description|required|
|----|-----------|--------|
|host|AgilePlace Url (https://mycompany.leankit.com)|yes|
|apiToken|API token with write access to your AgilePlace board|yes|
|cardId|Id of the card|yes|
|tag|Tag to add to the card|yes|

#### Example workflow step
```
- name: add tag to card
uses: leankit/github-actions/[email protected]
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
cardId: 12345
tag: deployed
```
#### Outputs
* error; error message if failed

-----------
### Block Card
Block or unblock a card
Expand All @@ -97,7 +121,7 @@ Block or unblock a card
#### Example workflow step
```
- name: block card
uses: leankit/github-actions/blockCard@v1.5
uses: leankit/github-actions/blockCard@v1.6
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
Expand Down Expand Up @@ -127,7 +151,7 @@ Create a new card
#### Example workflow step
```
- name: create card
uses: leankit/github-actions/createCard@v1.5
uses: leankit/github-actions/createCard@v1.6
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
Expand All @@ -139,6 +163,55 @@ Create a new card
#### Outputs
* error; error message if failed
* createdCardId; newly created card id
-----------
### Get Card Data
Get the data for a card by id
#### Input Params
|name|description|required|
|----|-----------|--------|
|host|AgilePlace Url (https://mycompany.leankit.com)|yes|
|apiToken|API token with read access to your AgilePlace board|yes|
|cardId|Id of the card|yes|

#### Example workflow step
```
- name: get card data
uses: leankit/github-actions/[email protected]
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
cardId: 12345
```
#### Outputs
* error; error message if failed
* cardData; JSON string containing the card data

-----------
### Has Tag
Check if a card has a specific tag (case insensitive)
#### Input Params
|name|description|required|
|----|-----------|--------|
|host|AgilePlace Url (https://mycompany.leankit.com)|yes|
|apiToken|API token with read access to your AgilePlace board|yes|
|cardId|Id of the card|yes|
|tag|Tag to check for on the card|yes|

#### Example workflow step
```
- name: check if card has tag
uses: leankit/github-actions/[email protected]
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
cardId: 12345
tag: deployed
```
#### Outputs
* error; error message if failed
* hasTag; whether the tag exists on the card (true/false)
* tags; list of all tags on the card

-----------
### Move Card
#### Input Params
Expand All @@ -152,7 +225,7 @@ Create a new card
#### Example workflow step
```
- name: move card
uses: leankit/github-actions/moveCard@v1.5
uses: leankit/github-actions/moveCard@v1.6
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
Expand All @@ -178,7 +251,7 @@ Although they are not technically required, you must specify either `assignUserI
#### Example workflow step
```
- name: assign users to cards
uses: leankit/github-actions/assignUsers@v1.5
uses: leankit/github-actions/assignUsers@v1.6
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
Expand All @@ -203,7 +276,7 @@ Note: the `customFields` input is available to receive custom field information
#### Example workflow step
```
- name: validate required fields
uses: leankit/github-actions/validateCustomFields@v1.5
uses: leankit/github-actions/validateCustomFields@v1.6
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
Expand Down Expand Up @@ -233,7 +306,7 @@ Valid formats that will be identified as a card id:
```
- name: get card id
id: getCardId
uses: leankit/github-actions/extractCardId@v1.5
uses: leankit/github-actions/extractCardId@v1.6
with:
inputText: ${{ github.event.pull_request.title }}
```
Expand All @@ -256,7 +329,7 @@ Initiate external automation event on a board
```
- name: initiate board event
id: initiateBoardEvent
uses: leankit/github-actions/initiateBoardEvent@v1.5
uses: leankit/github-actions/initiateBoardEvent@v1.6
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
Expand All @@ -281,7 +354,7 @@ Initiate external automation event on a card
```
- name: initiate card event
id: initiateCardEvent
uses: leankit/github-actions/initiateCardEvent@v1.5
uses: leankit/github-actions/initiateCardEvent@v1.6
with:
host: https://YOUR-ACCOUNT.leankit.com/
apiToken: ${{ secrets.MY_API_TOKEN }}
Expand Down Expand Up @@ -317,7 +390,8 @@ Before you run the `act` tests, you'll need to create a `test_payload.json` file
"client_payload": {
"common": {
"host": "https://YOURHOST.localkanban.com",
"apiToken": "YOUR_API_TOKEN"
"apiToken": "YOUR_API_TOKEN",
"cardId": "10114257503"
},
"extractCardId": {
"title": "My cool new PR (card: 10121557844)"
Expand All @@ -340,8 +414,10 @@ Before you run the `act` tests, you'll need to create a `test_payload.json` file
"requiredCustomFields": "github owner, github repository"
},
"addComment": {
"cardId": "10114257503",
"comment": "custom fields lookin' good!"
},
"addTag": {
"tag": "my-tag"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion addComment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ outputs:
error:
description: Status message for errors
runs:
using: "node20"
using: "node24"
main: "dist/index.js"
4 changes: 3 additions & 1 deletion addComment/dist/index.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions addTag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Add a tag to a card"
description: "Add a tag to a card"
inputs:
host:
description: AgilePlace Url (https://mycompany.leankit.com)
required: true
apiToken:
description: Api token with write access to your AgilePlace board
required: true
cardId:
description: Id of the card
required: true
tag:
description: Tag to add to the card
required: true
outputs:
error:
description: Status message for errors
runs:
using: "node24"
main: "dist/index.js"
3 changes: 3 additions & 0 deletions addTag/dist/index.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions addTag/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use strict";

const leankitApiFactory = require( "../leankit/api" );
const { getInputParams, reportError, validateLeankitUrl } = require( "../leankit/helpers" );

( async () => {
const [
host,
apiToken,
cardId,
tag
] = getInputParams( {
required: [ "host", "apiToken", "cardId", "tag" ]
} );

validateLeankitUrl( "host", host );

const { addTag } = leankitApiFactory( host, apiToken );

await addTag( cardId, tag );
} )().catch( ex => {
reportError( "addTag", ex );
} );
Loading