forked from ctriolo/action-find-or-create-linear-issue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
86 lines (83 loc) · 4.22 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: "Find or Create Linear Issue and Prefix PR"
description: "Ensure's every Pull Request has a Linear Issue associated with it and is displayed prominently in the title."
branding:
icon: "check-square"
color: "green"
inputs:
linear-api-key:
description: "Linear API key generated from https://linear.app/settings/api"
required: true
linear-team-key:
description: "Team key (e.g. ENG) for the Linear issue to create."
required: true
linear-created-issue-state-id:
description: "Team state ID for the created Linear issue."
linear-created-issue-title-prefix:
description: "Title prefix for the created Linear issue."
linear-issue-label-ids:
description: "Comma deliminated label ids"
github-token:
description: "GitHub token required to modify the PR title."
required: true
outputs:
linear-issue-id:
description: "The Linear issue's unique identifier. (UUID)"
value: ${{ steps.find.outputs.linear-issue-id || steps.create.outputs.linear-issue-id}}
linear-issue-identifier:
description: "The Linear issue's human readable identifier. (e.g. `ENG-123`)"
value: ${{ steps.find.outputs.linear-issue-identifier || steps.create.outputs.linear-issue-identifier}}
linear-issue-number:
description: "The Linear issue's number. (e.g. the `123` of `ENG-123`)"
value: ${{ steps.find.outputs.linear-issue-number || steps.create.outputs.linear-issue-number}}
linear-issue-title:
description: "The Linear issue's title."
value: ${{ steps.find.outputs.linear-issue-title || steps.create.outputs.linear-issue-title}}
linear-issue-description:
description: "The Linear issue's description."
value: ${{ steps.find.outputs.linear-issue-description || steps.create.outputs.linear-issue-description}}
linear-issue-url:
description: "The Linear issue's URL. (e.g. `https://...`)"
value: ${{ steps.find.outputs.linear-issue-url || steps.create.outputs.linear-issue-url}}
linear-team-id:
description: "The Linear teams unique identifier. (UUID)"
value: ${{ steps.find.outputs.linear-team-id || steps.create.outputs.linear-team-id}}
linear-team-key:
description: "The Linear teams key/prefix (e.g. `ENG`)"
value: ${{ steps.find.outputs.linear-team-key || steps.create.outputs.linear-team-key}}
did-create:
description: "`true` if linear issue was created using this action. `false` otherwise."
value: ${{ steps.find.outcome == 'failure' && steps.create.outcome == 'success' }}
runs:
using: "composite"
steps:
- name: Find the Linear Issue.
continue-on-error: true
id: find
uses: ctriolo/[email protected]
with:
linear-api-key: ${{inputs.linear-api-key}}
linear-issue-label-ids: ${{inputs.linear-issue-label-ids}}
- name: Create the Linear Issue if no identifier found.
id: create
if: ${{always() && steps.find.outcome == 'failure'}}
uses: ctriolo/[email protected]
with:
linear-api-key: ${{inputs.linear-api-key}}
linear-team-key: ${{inputs.linear-team-key}}
linear-issue-title: "${{inputs.linear-created-issue-title-prefix}}${{github.event.pull_request.title}}"
linear-issue-description: ${{github.event.pull_request.body}}
linear-issue-state-id: ${{inputs.linear-created-issue-state-id}}
linear-attachment-url: ${{github.event.pull_request.html_url}}
linear-attachment-title: "(#${{github.event.pull_request.number}}) ${{github.event.pull_request.title}}"
linear-issue-label-ids: ${{inputs.linear-issue-label-ids}}
- name: Prepend the title with the Linear issue identifier.
# Not enforcing that the found or created task is at the start for in the case of multiple tasks in the title.
if: ${{!contains(github.event.pull_request.title, steps.find.outputs.linear-issue-identifier || steps.create.outputs.linear-issue-identifier)}}
shell: bash
env:
PR_URL: ${{github.event.pull_request.html_url}}
PR_TITLE: ${{github.event.pull_request.title}}
ISSUE_IDENTIFIER: ${{ steps.find.outputs.linear-issue-identifier || steps.create.outputs.linear-issue-identifier}}
GITHUB_TOKEN: ${{inputs.github-token}}
run: |
gh pr edit "$PR_URL" --title "$ISSUE_IDENTIFIER: $PR_TITLE"