Skip to content

Commit 80978ac

Browse files
author
Alex Page
committed
2 parents 75411c4 + 541882c commit 80978ac

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
automate-project-columns:
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: alex-page/github-project-automation-plus@v0.7.1
32+
- uses: alex-page/github-project-automation-plus@v0.8.0
3333
with:
3434
project: Backlog
3535
column: Triage
@@ -51,7 +51,7 @@ jobs:
5151
automate-project-columns:
5252
runs-on: ubuntu-latest
5353
steps:
54-
- uses: alex-page/github-project-automation-plus@v0.7.1
54+
- uses: alex-page/github-project-automation-plus@v0.8.0
5555
with:
5656
project: Backlog
5757
column: To do
@@ -69,7 +69,7 @@ Change these options in the workflow `.yml` file to meet your GitHub project nee
6969
| `project` | The name of the project | `Backlog` |
7070
| `column` | The column to create or move the card to | `Triage` |
7171
| `repo-token` | The personal access token | `${{ secrets.GITHUB_TOKEN }}` |
72-
| `action` | This determines the type of the action to be performed on the card, Default: `update` | `update`, `delete`, `archive` |
72+
| `action` | This determines the type of the action to be performed on the card, Default: `update` | `update`, `delete`, `archive`, `add` |
7373

7474
## Personal access token
7575

@@ -112,6 +112,7 @@ You may need to enable policy settings to allow running workflows from forks. Pl
112112
113113
## Release History
114114
115+
- v0.8.0 - Add new action type 'add'
115116
- v0.7.1 - Move Node.js version back to v12
116117
- v0.7.0 - Update documentation and dependencies
117118
- v0.6.0 - Add support for `pull_request_target` and `pull_request_review`

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ inputs:
1313
required: true
1414
action:
1515
description: |
16-
Can be `update`, `delete` or `archive`. This determines the type of the action
16+
Can be `update`, `delete` or `archive` or `add`. This determines the type of the action
1717
to be performed on the card
1818
required: false
1919
default: "update"

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-project-automation-plus",
3-
"version": "0.6.0",
3+
"version": "0.8.0",
44
"description": "🤖 Automate GitHub Project cards with any webhook event",
55
"private": true,
66
"main": "dist/index.js",
@@ -39,4 +39,4 @@
3939
"files": [
4040
"dist/index.js"
4141
]
42-
}
42+
}

src/generate-mutation-query.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ const generateMutationQuery = (data, projectName, columnName, contentId, action)
8888
}) { clientMutationId } }`;
8989
}
9090

91+
if (action === 'add' && !cardLocations[mutation].cardId) {
92+
// Add issue if the card does not exist in the project
93+
return `mutation {
94+
addProjectCard( input: {
95+
contentId: "${contentId}",
96+
projectColumnId: "${cardLocations[mutation].columnId}"
97+
}) { clientMutationId } }`;
98+
}
99+
91100
return undefined;
92101
});
93102

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const generateMutationQuery = require('./generate-mutation-query');
2929

3030
// A list of columns that line up with the user entered project and column
3131
const mutationQueries = generateMutationQuery(resource, project, column, nodeId, action);
32-
if ((action === 'delete' || action === 'archive') && mutationQueries.length === 0) {
32+
if ((action === 'delete' || action === 'archive' || action === 'add') && mutationQueries.length === 0) {
3333
console.log('✅ There is nothing to do with card');
3434
return;
3535
}

tests/generate-mutation-query.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ test('generateMutationQuery delete the card when it is in the project already',
6666
]);
6767
});
6868

69+
test('generateMutationQuery skip issue addition when the card already exists in the project', t => {
70+
t.deepEqual(generateMutationQuery(moveData, project, column, nodeId, 'add'), []);
71+
});
72+
6973
const addData = {
7074
projectCards: {
7175
nodes: []

0 commit comments

Comments
 (0)