|
1 |
| -# build-issue-dependencies-graph |
| 1 | +# maxim-lobanov/build-issue-dependencies-graph |
| 2 | + |
| 3 | +This action is intended for building dependencies graph between issues in epic, rendering mermaid diagram with this graph and automatically updating epic issue body with diagram. |
| 4 | +It can be useful during work on big epics where it is tricky to keep all dependencies in mind. |
| 5 | + |
| 6 | +## Parameters |
| 7 | +| Parameter | Description | |
| 8 | +|-|-| |
| 9 | +| `root-issue-url` | Url of the root issue | |
| 10 | +| `section-title` | Title of markdown section where mermaid chart should be placed | |
| 11 | +| `github-token` | GitHub API Token with read and write access to root issue and read access to all issues in the tasklist | |
| 12 | +| `include-legend` | Set this option to include legend to mermaid diagram | |
| 13 | +| `include-finish-node` | Set this option to include finish node to mermaid diagram | |
| 14 | +| `dry-run` | Set this option to not update root issue with updated mermaid diagram and only print new diagram to output | |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +1. Update root issue body to include task list with all children issues: |
| 19 | + ``` |
| 20 | + - [ ] https://github.com/owner/repo/issues/2 |
| 21 | + - [ ] https://github.com/owner/repo/issues/3 |
| 22 | + - [ ] https://github.com/owner/repo/issues/4 |
| 23 | + ... |
| 24 | + ``` |
| 25 | +2. Create an empty section in root issue body to which mermaid diagram will be inserted: |
| 26 | + ``` |
| 27 | + ... |
| 28 | + ## Spec Diagram |
| 29 | + ... |
| 30 | + ``` |
| 31 | +3. Update all children issues to define their dependencies in issues body using one of the following syntax: |
| 32 | + ``` |
| 33 | + Depends on https://github.com/owner/repo/issues/2, https://github.com/owner/repo/issues/3 |
| 34 | + Depends on: https://github.com/owner/repo/issues/2 https://github.com/owner/repo/issues/3 |
| 35 | + Dependencies: https://github.com/owner/repo/issues/2, https://github.com/owner/repo/issues/3 |
| 36 | + ``` |
| 37 | + Any of the format above can be used one or multiple times in issue body. Any separator can be used for issues in line. |
| 38 | +
|
| 39 | +4. Add workflow to invoke this action: |
| 40 | + ```yml |
| 41 | + jobs: |
| 42 | + update-diagram: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - uses: maxim-lobanov/build-issue-dependencies-graph@v1 |
| 46 | + with: |
| 47 | + root-issue-url: 'https://github.com/owner/repo/issues/1' |
| 48 | + section-title: 'Spec Diagram' |
| 49 | + github-token: '${{ secrets.GITHUB_TOKEN }}' |
| 50 | + include-legend: true |
| 51 | + include-finish-node: true |
| 52 | + ``` |
| 53 | +
|
| 54 | +## Advanced usage |
| 55 | +
|
| 56 | +### Workflow to trigger action manually |
| 57 | +```yml |
| 58 | +on: |
| 59 | + workflow_dispatch: |
| 60 | + inputs: |
| 61 | + root-issue-url: |
| 62 | + description: 'Root issue url' |
| 63 | + required: true |
| 64 | + type: string |
| 65 | + section-title: |
| 66 | + description: 'Section title' |
| 67 | + required: true |
| 68 | + type: string |
| 69 | + include-legend: |
| 70 | + description: 'Include legend' |
| 71 | + type: boolean |
| 72 | + include-finish-node: |
| 73 | + description: 'Include finish node' |
| 74 | + type: boolean |
| 75 | + dry-run: |
| 76 | + description: 'Dry run' |
| 77 | + type: boolean |
| 78 | +
|
| 79 | +jobs: |
| 80 | + run: |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - uses: maxim-lobanov/build-issue-dependencies-graph@v1 |
| 84 | + name: 'Build issues dependency graph' |
| 85 | + id: build-issue-dependencies-graph |
| 86 | + with: |
| 87 | + root-issue-url: '${{ github.event.inputs.root-issue-url }}' |
| 88 | + section-title: '${{ github.event.inputs.section-title }}' |
| 89 | + github-token: '${{ secrets.GITHUB_TOKEN }}' |
| 90 | + include-legend: '${{ github.event.inputs.include-legend }}' |
| 91 | + include-finish-node: '${{ github.event.inputs.include-finish-node }}' |
| 92 | + dry-run: '${{ github.event.inputs.dry-run }}' |
| 93 | +``` |
| 94 | + |
| 95 | +### Workflow to trigger action on schedule |
| 96 | +``` |
| 97 | +on: |
| 98 | + schedule: |
| 99 | + - cron: '* */12 * * *' # Twice per day |
| 100 | +
|
| 101 | +jobs: |
| 102 | + run: |
| 103 | + runs-on: ubuntu-latest |
| 104 | + strategy: |
| 105 | + fail-fast: false |
| 106 | + matrix: |
| 107 | + include: |
| 108 | + - root-issue-url: 'https://github.com/owner/repo/issues/1' |
| 109 | + section-title: 'Spec Diagram' |
| 110 | + - root-issue-url: 'https://github.com/owner/repo/issues/2' |
| 111 | + section-title: 'Spec Diagram' |
| 112 | + steps: |
| 113 | + - uses: maxim-lobanov/build-issue-dependencies-graph@v1 |
| 114 | + name: 'Build issues dependency graph' |
| 115 | + id: build-issue-dependencies-graph |
| 116 | + with: |
| 117 | + root-issue-url: '${{ github.event.inputs.root-issue-url }}' |
| 118 | + section-title: '${{ github.event.inputs.section-title }}' |
| 119 | + github-token: '${{ secrets.GITHUB_TOKEN }}' |
| 120 | + include-legend: true |
| 121 | + include-finish-node: true |
| 122 | +``` |
| 123 | + |
| 124 | + |
| 125 | +## Mermaid examples |
| 126 | + |
| 127 | +```mermaid |
| 128 | +flowchart TD |
| 129 | +
|
| 130 | +%% <Legend> |
| 131 | +legend --> start |
| 132 | +subgraph legend["Legend"] |
| 133 | + direction LR; |
| 134 | + notstarted("Issue is not started"):::notstarted; |
| 135 | + started("Issue is in progress"):::started; |
| 136 | + completed("Issue is done"):::completed; |
| 137 | + notstarted --> started --> completed; |
| 138 | +end |
| 139 | +
|
| 140 | +%% </Legend> |
| 141 | +
|
| 142 | +
|
| 143 | +%% <CSS> |
| 144 | +
|
| 145 | +classDef notstarted fill:#FFF,color:#000; |
| 146 | +classDef started fill:#fae17d,color:#000; |
| 147 | +classDef completed fill:#ccffd8,color:#000; |
| 148 | +
|
| 149 | +%% </CSS> |
| 150 | +
|
| 151 | +
|
| 152 | +%% <Issues> |
| 153 | +
|
| 154 | +start("Start"):::notstarted; |
| 155 | +
|
| 156 | +issue1488484564("[TEST ISSUE] Child issue 1"):::completed; |
| 157 | +click issue1488484564 href "https://github.com/maxim-lobanov/build-issue-dependencies-graph/issues/2" _blank; |
| 158 | +
|
| 159 | +issue1488484695("[TEST ISSUE] Child issue 2"):::completed; |
| 160 | +click issue1488484695 href "https://github.com/maxim-lobanov/build-issue-dependencies-graph/issues/3" _blank; |
| 161 | +
|
| 162 | +issue1488484833("[TEST ISSUE] Child issue 3"):::notstarted; |
| 163 | +click issue1488484833 href "https://github.com/maxim-lobanov/build-issue-dependencies-graph/issues/4" _blank; |
| 164 | +
|
| 165 | +finish("Finish"):::notstarted; |
| 166 | +
|
| 167 | +%% </Issues> |
| 168 | +
|
| 169 | +
|
| 170 | +%% <Dependencies> |
| 171 | +
|
| 172 | +start --> issue1488484564; |
| 173 | +start --> issue1488484695; |
| 174 | +issue1488484564 --> issue1488484833; |
| 175 | +issue1488484695 --> issue1488484833; |
| 176 | +issue1488484833 --> finish; |
| 177 | +
|
| 178 | +%% </Dependencies> |
| 179 | +
|
| 180 | +``` |
0 commit comments