File tree Expand file tree Collapse file tree 1 file changed +86
-0
lines changed
gh-actions/github/issue/get Expand file tree Collapse file tree 1 file changed +86
-0
lines changed Original file line number Diff line number Diff line change 1+ inputs :
2+ author :
3+ type : string
4+ default :
5+ body :
6+ type : string
7+ default :
8+ create :
9+ type : boolean
10+ default : false
11+ label :
12+ type : string
13+ default :
14+ repo :
15+ type : string
16+ default : ${{ github.repository }}
17+ title :
18+ type : string
19+ required : true
20+ GITHUB_TOKEN :
21+ type : string
22+ required : true
23+
24+ outputs :
25+ id :
26+ value : ${{ steps.issue-id.outputs.value || steps.issue-created.outputs.id }}
27+
28+
29+ runs :
30+ using : composite
31+ steps :
32+ - run : |
33+ ISSUE_SEARCH=(
34+ "is:issue"
35+ "is:open"
36+ "repo:${{ inputs.repo }}"
37+ "in:title:\\\"${{ inputs.title }}\\\"")
38+ if [[ -n "${{ inputs.label }}" ]]; then
39+ ISSUE_SEARCH+=("label:${{ inputs.label }}")
40+ fi
41+ if [[ -n "${{ inputs.author }}" ]]; then
42+ ISSUE_SEARCH+=("author:${{ inputs.author }}")
43+ fi
44+ RESULT="$(gh api graphql -f query="
45+ {
46+ search(query: \"${ISSUE_SEARCH[*]}\", type: ISSUE, first: 1) {
47+ edges {
48+ node {
49+ ... on Issue {
50+ title
51+ url
52+ number
53+ }
54+ }
55+ }
56+ }
57+ }")"
58+ echo "result=${RESULT}" >> $GITHUB_OUTPUT
59+ id: issue-query
60+ shell: bash
61+ env:
62+ GH_TOKEN: "${{ inputs.GITHUB_TOKEN }}"
63+ -
uses :
envoyproxy/toolshed/gh-actions/[email protected] 64+ id : issue-id
65+ with :
66+ input : ${{ steps.issue-query.outputs.result }}
67+ options : -r
68+ filter : |
69+ .data.search.edges[0].node.number // ""
70+
71+ - run : |
72+ ISSUE_ARGS=(
73+ "--title" "${{ inputs.title }}"
74+ "--body" "${{ inputs.body }}")
75+ if [[ -n "${{ inputs.label }}" ]]; then
76+ ISSUE_ARGS+=("--label" "${{ inputs.label }}")
77+ fi
78+ ISSUE=$(
79+ gh issue create "${ISSUE_ARGS[@]}"\
80+ | grep -oP '(?<=issues/)\d+')
81+ echo "id=${ISSUE}" >> $GITHUB_OUTPUT
82+ if: ${{ inputs.create && ! steps.issue-id.outputs.value }}
83+ id: issue-created
84+ shell: bash
85+ env:
86+ GH_TOKEN: "${{ inputs.GITHUB_TOKEN }}"
You can’t perform that action at this time.
0 commit comments