Skip to content

Commit ef4d6af

Browse files
committed
feat: update to use graphql, support full flow
1 parent c4a9b8c commit ef4d6af

File tree

7 files changed

+753
-133
lines changed

7 files changed

+753
-133
lines changed

README.md

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,66 @@
11
# action-project-manager
22

3-
This is relatively simple a GitHub Action that can be used to manage issues in a project.
3+
This is a GitHub Action that can be used to manage issues in a project.
44

55
## Usage
66

7-
This action is meant to be a building block for more complex behaviors. The basic idea is that when some issue-related event happens, this action can be used to move the affected issue to a particular column in a project.
8-
97
```yaml
10-
# .github/workflows/issue-created.yaml
11-
name: Issue Created
8+
# .github/workflows/update-issue.yaml
9+
name: Update issue
1210

1311
on:
1412
issues:
15-
types: [opened]
13+
pull_request: [opened, closed, reopened]
1614

1715
jobs:
18-
move-issue:
16+
update-issue:
1917
runs-on: ubuntu-latest
2018
steps:
21-
- uses: actions/checkout@v2
2219
- uses: theintern/[email protected]
2320
with:
2421
github-token: ${{ secrets.GITHUB_TOKEN }}
2522
project: Development
26-
column: Done
23+
auto-add: true
24+
triage-column: Triage
25+
triage-label: needs-triage
26+
todo-column: To do
27+
working-column: In progress
28+
done-column: Done
2729
```
2830
29-
```yaml
30-
# .github/workflows/issue-assigned.yaml
31-
name: Issue Assigned
31+
## Configuration
3232
33-
on:
34-
issues:
35-
types: [assigned]
33+
| Property | Required | Value |
34+
| ---------------- | -------- | ----------------------------------------------------------- |
35+
| `github-token` | Yes | A GitHub API token (`GITHUB_TOKEN` is available by default) |
36+
| `project` | Yes | The project being managed |
37+
| `auto-add` | No | If true, all new issues are added to the project |
38+
| `triage-column` | No | Column name for new, unassigned issues |
39+
| `triage-label` | No | Label to apply to new issues |
40+
| `todo-column` | No | Column name for triaged issues |
41+
| `working-column` | No | Column name for in-progress issues |
42+
| `done-column` | No | Column name for completed issues |
3643

37-
jobs:
38-
move-issue:
39-
runs-on: ubuntu-latest
40-
steps:
41-
- uses: actions/checkout@v2
42-
- uses: theintern/[email protected]
43-
with:
44-
github-token: ${{ secrets.GITHUB_TOKEN }}
45-
project: Development
46-
column: In progress
47-
```
44+
## How it works
4845

49-
```yaml
50-
# .github/workflows/issue-completed.yaml
51-
name: Issue Completed
46+
Only issues should be added to a project, not PRs. Linked PRs are accessible
47+
through the issue cards.
5248

53-
on:
54-
issues:
55-
types: [closed]
49+
Note that any rule below that mentions an optional config property will only be
50+
executed if that property is defined.
5651

57-
jobs:
58-
move-issue:
59-
runs-on: ubuntu-latest
60-
steps:
61-
- uses: actions/checkout@v2
62-
- uses: theintern/[email protected]
63-
with:
64-
github-token: ${{ secrets.GITHUB_TOKEN }}
65-
project: Development
66-
column: Done
67-
```
52+
Rules:
53+
54+
- If `auto-add` is true, new issues will be added to `triage-column` and have
55+
`triage-label` set
56+
- Issues in `triage-column` will be moved to `todo-column` when `triage-label`
57+
is removed
58+
- Issues that are in `todo-column` or `triage-column` will be moved to
59+
`working-column` when they are assigned
60+
- When a PR is opened that links to an issue in `triage-column` or
61+
`todo-column`, that issue will be moved to `working-column`
62+
- An issue in `working-column` that is unassigned with be moved to
63+
`todo-columnn`
64+
- Closed issues are moved to `done-column`
65+
- Re-opened issues are moved to `working-column` if they are assigned, or to
66+
`todo-column` if not

dist/index.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ class Issue {
19281928
}
19291929
`;
19301930
const response = yield this.octokit.graphql(query);
1931-
const resource = response["resource"];
1931+
const resource = response['resource'];
19321932
const cards = (_a = resource.projectCards.nodes) !== null && _a !== void 0 ? _a : [];
19331933
// Project columns must exist, because this action only makes sense with a
19341934
// valid project
@@ -4422,25 +4422,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
44224422
});
44234423
};
44244424
Object.defineProperty(exports, "__esModule", { value: true });
4425-
/**
4426-
* Actions
4427-
*
4428-
* - New issues will have the "triage" label auto-assigned (if one is configured)
4429-
* - Issues with the "triage" label will be added to the Triage column (if one
4430-
* is configured)
4431-
* - Issues in the triage column will be moved to todo when the triage label is removed
4432-
* - Newly assigned issues that are in todo or triage go to the working column
4433-
* - todo issues that are assigned go to the working column
4434-
* - When a PR is opened that links to an issue, that issue will be moved to
4435-
* the working column
4436-
* - working issues that are de-assigned go back to todo
4437-
* - Issues that are on the board and are closed go to done
4438-
* - Closed issues on the board that are re-opened go back to working
4439-
* - When issues are added to a column, they should be added in priority order,
4440-
* with priority-high at the top and priority-low at the bottom.
4441-
* - Only issues go on the board, not PRs. PRs will be accessible through issue
4442-
* links.
4443-
*/
44444425
const core_1 = __webpack_require__(470);
44454426
const github_1 = __webpack_require__(469);
44464427
const issue_1 = __webpack_require__(163);
@@ -4586,7 +4567,7 @@ function main() {
45864567
issue.isInColumn(config.workingColumnName) &&
45874568
config.todoColumnName &&
45884569
!issue.isAssigned() &&
4589-
!issue.linkedPrs.some(pr => !pr.closed)) {
4570+
!issue.linkedPrs.some((pr) => !pr.closed)) {
45904571
core_1.info(`Moving issue ${issue.number} to todo column`);
45914572
yield issue.moveToColumn(config.todoColumnName);
45924573
}
@@ -25873,7 +25854,6 @@ function getAction(context) {
2587325854
}
2587425855
exports.getAction = getAction;
2587525856
function getConfig() {
25876-
const triagedLabels = core_1.getInput('triaged-labels');
2587725857
const config = {
2587825858
token: core_1.getInput('github-token'),
2587925859
projectName: core_1.getInput('project'),
@@ -25883,8 +25863,6 @@ function getConfig() {
2588325863
triageColumnName: core_1.getInput('triage-column'),
2588425864
// Label that will be applied to triage issues
2588525865
triageLabel: core_1.getInput('triage-label'),
25886-
// Labels that indicate an issue has been triaged
25887-
triagedLabels: triagedLabels ? triagedLabels.split(/\s*,\s*/) : null,
2588825866
// Column for "ready" issues
2588925867
todoColumnName: core_1.getInput('todo-column'),
2589025868
// Column for "in-progress" issues

0 commit comments

Comments
 (0)