|
1 | | -name: Create Documentation Linear Issue |
| 1 | +name: Create Linear Issue on PR Merge |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_call: |
| 5 | + inputs: |
| 6 | + label: |
| 7 | + required: true |
| 8 | + description: The PR label which should trigger an issue being created. |
| 9 | + type: string |
| 10 | + issue-prefix: |
| 11 | + required: false |
| 12 | + description: A prefix to add to the issue title. |
| 13 | + default: "AUTO-GENERATED" |
5 | 14 | secrets: |
6 | 15 | linear-api-key: |
7 | 16 | required: true |
8 | | - description: An API key to use to create an issue for documentation. |
9 | | - linear-label-id: |
| 17 | + description: An API key to use to create an issue. |
| 18 | + issue-label-id: |
10 | 19 | required: true |
11 | | - description: The ID of the label to be added to the issue. |
12 | | - linear-docs-team-id: |
| 20 | + description: The ID of a pre-existing label to add to the created issue. |
| 21 | + issue-team-id: |
13 | 22 | required: true |
14 | | - description: The ID of the documentation team in Linear. |
| 23 | + description: The ID of the team to create the issue under within Linear. |
15 | 24 |
|
16 | 25 | jobs: |
17 | 26 | create-issue: |
18 | 27 | if: > |
19 | 28 | github.event.pull_request.merged == true && |
20 | | - contains(github.event.pull_request.labels.*.name, 'docs: needed') |
| 29 | + contains(github.event.pull_request.labels.*.name, ${{ inputs.label }}) |
21 | 30 | runs-on: ubuntu-latest |
22 | 31 | steps: |
23 | 32 | - name: Create Linear Issue |
24 | 33 | env: |
25 | 34 | LINEAR_API_KEY: ${{ secrets.linear-api-key }} |
26 | | - LINEAR_LABEL_ID: ${{ secrets.linear-label-id }} |
27 | | - LINEAR_DOCS_TEAM_ID: ${{ secrets.linear-docs-team-id }} |
| 35 | + ISSUE_LABEL_ID: ${{ secrets.issue-label-id }} |
| 36 | + ISSUE_TEAM_ID: ${{ secrets.issue-team-id }} |
| 37 | + ISSUE_PREFIX: ${{ inputs.issue-prefix }} |
28 | 38 | PR_TITLE: ${{ github.event.pull_request.title }} |
29 | 39 | PR_URL: ${{ github.event.pull_request.html_url }} |
30 | 40 | run: | |
31 | | - desc= |
32 | 41 | PAYLOAD=$(jq -n \ |
33 | | - --arg t "DOC: $PR_TITLE" \ |
| 42 | + --arg t "$ISSUE_PREFIX: $PR_TITLE" \ |
34 | 43 | --arg d "PR: $PR_URL" \ |
35 | | - --arg id "$LINEAR_DOCS_TEAM_ID" \ |
36 | | - --arg l "$LINEAR_LABEL_ID" \ |
| 44 | + --arg id "$ISSUE_TEAM_ID" \ |
| 45 | + --arg l "$ISSUE_LABEL_ID" \ |
37 | 46 | '{ |
38 | 47 | query: "mutation($t:String!,$d:String!,$id:String!,$l:[String!]){issueCreate(input:{title:$t,description:$d,teamId:$id,labelIds:$l}){success issue{identifier url}}}", |
39 | 48 | variables: { t: $t, d: $d, id: $id, l: [$l] } |
|
0 commit comments