Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ribtoks/parent-issue-update
Browse files Browse the repository at this point in the history
  • Loading branch information
ribtoks committed Jun 5, 2020
2 parents 973f699 + 20b1a78 commit 08c741b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

GitHub Action that updates parent issues that are linked by child issues. When child issue is closed or opened, referenced parent is updated. You can use this to create Epics using GitHub Issues or simply for better tracking of dependent issues. Issue hierarchies are supported too.

In order to link child issues to parent issues, add a line `Parent: #1234` or `Epic: #1234` or `Parent issue: #1234` anywhere in the child issue body.

## Screenshot

![Update result](screenshot.png "Example of created issue")
Expand All @@ -16,7 +18,7 @@ Create a workflow file in your `.github/workflows/` directory with the following
### Basic example

```yaml
name: Parent issue workflow
name: Epics workflow
on:
schedule:
- cron: '0 5 * * *'
Expand All @@ -32,11 +34,11 @@ jobs:
REPO: ${{ github.repository }}
```
In order to link child issues to parent issues, add a line `Parent: #1234` or `Epic: #1234` or `Parent issue: #1234` anywhere in the issue body. You can have as many nested levels as you need.
> **NOTE:** Please note that currently GitHub has 5000 requests per hour limit so if you are running it on a fresh repository and you have really many issues, you may hit this limit.
This action was designed to run on schedule instead of per issue update event in order to reduce amount of possible race conditions when multiple issues are updated at once and multiple worflows are started in parallel. Currently GitHub Actions do not support cancelling parallel jobs. When this will be supported, it will be safe to use this action per `issue` `opened`/`reopened`/`closed` trigger.

> **NOTE:** Please note that currently GitHub has 5000 requests per hour limit so if you are running it on a fresh repository and you have lots of todos in comments, you may hit this limit.
You can use this action together with [TODO issue generator](https://github.com/ribtoks/tdg-github-action) in order to link all TODO isues to the parent issue for better tracking (if you use a specific syntax in the TODO body - see [docs](https://github.com/ribtoks/tdg-github-action#todo-comments)).

### Inputs

Expand All @@ -47,14 +49,14 @@ This action was designed to run on schedule instead of per issue update event in
| `DRY_RUN` | Do not update real real issues (used for debugging) |
| `SYNC_DAYS` | Update parent issues for issue changes in the last `SYNC_DAYS` (defaults to `1`) |
| `MAX_LEVELS` | Keep this deep hierarchy in parent issues (defaults to `0` - unlimited)
| `ADD_CHANGELOG` | Add a short summary to parent issue with the update changelog |
| `UPDATE_CLOSED` | Update closed parent issues too |
| `ADD_CHANGELOG` | Add a comment with the update changelog to parent issue (default `1` - enabled) |
| `UPDATE_CLOSED` | Update closed parent issues too (default `0` - disabled) |

Flag values like `DRY_RUN` or `ADD_CHANGELOG` use values `1`/`true`/`y` as ON switch.

If you want to run this action every week, you need to update `SYNC_DAYS` to `7` and update cron job schedule in Action syntax to be `0 0 0 * *` (use [crontab guru](https://crontab.guru/) for help).

If you want to sync all issues at every run, use `all` as a value for `SYNC_DAYS`.
If you want to sync all issues at every run, use `all` as a value for `SYNC_DAYS`. This may be useful on the initial integration in the repository.

### Outputs

Expand Down
7 changes: 6 additions & 1 deletion issue_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ func (t *tree) Issues() []*Issue {
children = append(children, t.issues[i])
}

pi := t.issues[p]
pi, ok := t.issues[p]
if !ok {
log.Printf("Failed to find an issue. issue=%v", p)
continue
}

pi.Children = children

issues = append(issues, pi)
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,17 @@ func main() {
}

if len(ghIssues) == 0 {
fmt.Println(fmt.Sprintf(`::set-output name=updatedIssues::%s`, "1"))
return
}

tr := NewTree(ghIssues)
issues := tr.Issues()
missing, err := svc.fetchIssuesByID(tr.missing)
if err != nil {
log.Panic(err)
}
tr.AddParentIssues(missing)
issues := tr.Issues()

e := &Editor{
MaxLevels: svc.env.maxLevels,
Expand Down

0 comments on commit 08c741b

Please sign in to comment.