Skip to content

Commit e3ce961

Browse files
committed
✨ Add action for updating issue
1 parent b96e0be commit e3ce961

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

issues/update/action.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Update issue
2+
description: |
3+
A composite action for updating an existing github issue.
4+
This action will update _all_ fields of the issue, and thus should be used
5+
sparingly. Consider using the `issues/add-*` or `issues/remove-*` series of
6+
steps to alter the issue in-place.
7+
This requires `issues: write` permissions in order to work correctly.
8+
9+
inputs:
10+
issue-number:
11+
required: false
12+
default: "0"
13+
description: |
14+
The issue number to comment on.
15+
If not specified, this will attempt to retrieve the issue number from the
16+
Github `context` variable.
17+
title:
18+
required: true
19+
description: "The title to use for the issue"
20+
body:
21+
required: false
22+
default: ""
23+
description: "The body text of the github issue"
24+
labels:
25+
required: false
26+
default: ""
27+
description: "A list of labels to add, separated by newlines."
28+
assignees:
29+
required: false
30+
default: ""
31+
description: "A list of assignees to add, separated by newlines."
32+
owner:
33+
required: false
34+
default: ""
35+
description: "The repository owner"
36+
repo:
37+
required: false
38+
default: ""
39+
description: "The repository"
40+
retries:
41+
required: false
42+
default: "3"
43+
description: "The number of times to try retrying"
44+
retry-exempt-status-codes:
45+
required: false
46+
default: "400,401,403,404,422"
47+
description: "The retry exempt status codes"
48+
outputs:
49+
issue-number:
50+
value: ${{ steps.create.outputs.issue-number }}
51+
description: "The number of the created issue"
52+
issue-url:
53+
value: ${{ steps.create.outputs.issue-url }}
54+
description: "The HTTP URL of the newly created issue"
55+
56+
runs:
57+
using: "composite"
58+
steps:
59+
- name: Create issue
60+
id: create
61+
uses: actions/github-script@v7
62+
with:
63+
retries: ${{ inputs.retries }}
64+
retry-exempt-status-codes: ${{ inputs.retry-exempt-status-codes }}
65+
script: |
66+
const { data: issue } = await github.rest.issues.update({
67+
owner: `${{ inputs.owner }}` || context.repo.owner,
68+
repo: `${{ inputs.repo }}` || context.repo.repo,
69+
issue_number: ${{ inputs.issue-number }} || context.issue.number,
70+
labels: `${{ inputs.labels }}`.split(/[\n,]/).map(s => s.trim()).filter(s => s),
71+
assignees: `${{ inputs.assignees }}`.split(/[\n,]/).map(s => s.trim()).filter(s => s),
72+
title: `${{ inputs.title }}`,
73+
body: `${{ inputs.body }}`,
74+
})
75+
core.setOutput('issue-number', issue.number)
76+
core.setOutput('issue-url', issue.html_url)

0 commit comments

Comments
 (0)