Skip to content

Commit 257fb76

Browse files
authored
ci: automatically determine issue URL when invoked via issue label assignment (coder#20089)
Silly me forgot that `inputs.*` will likely be empty when invoked outside of `workflow_dispatch`. Sample run: https://github.com/coder/coder/actions/runs/18165531528/job/51706661391
1 parent 98262d8 commit 257fb76

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

.github/workflows/traiage.yaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,28 @@ jobs:
9494
fi
9595
echo "::notice::User ${GITHUB_USERNAME} verified as member of ${GITHUB_ORG} organization"
9696
97+
- name: Determine issue URL
98+
id: determine-issue-url
99+
env:
100+
INPUTS_ISSUE_URL: ${{ inputs.issue_url }}
101+
GITHUB_EVENT_ISSUE_HTML_URL: ${{ github.event.issue.html_url }}
102+
GITHUB_EVENT_NAME: ${{ github.event_name }}
103+
run: |
104+
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
105+
echo "issue_url=${INPUTS_ISSUE_URL}" >> "${GITHUB_OUTPUT}"
106+
exit 0
107+
elif [[ "${GITHUB_EVENT_NAME}" == "issues" ]]; then
108+
echo "issue_url=${GITHUB_EVENT_ISSUE_HTML_URL}" >> "${GITHUB_OUTPUT}"
109+
exit 0
110+
else
111+
echo "::error::Unsupported event type: ${GITHUB_EVENT_NAME}"
112+
exit 1
113+
fi
114+
97115
- name: Extract context key from issue
98116
id: extract-context
99117
env:
100-
ISSUE_URL: ${{ inputs.issue_url }}
118+
ISSUE_URL: ${{ steps.determine-issue-url.outputs.issue_url }}
101119
GH_TOKEN: ${{ github.token }}
102120
run: |
103121
issue_number="$(gh issue view "${ISSUE_URL}" --json number --jq '.number')"
@@ -151,7 +169,7 @@ jobs:
151169
CONTEXT_KEY: ${{ steps.extract-context.outputs.context_key }}
152170
GH_TOKEN: ${{ github.token }}
153171
GITHUB_REPOSITORY: ${{ github.repository }}
154-
ISSUE_URL: ${{ inputs.issue_url }}
172+
ISSUE_URL: ${{ steps.determine-issue-url.outputs.issue_url }}
155173
PREFIX: ${{ inputs.prefix }}
156174
RUN_ID: ${{ github.run_id }}
157175
TEMPLATE_PARAMETERS: ${{ secrets.TRAIAGE_TEMPLATE_PARAMETERS }}
@@ -207,7 +225,7 @@ jobs:
207225
CONTEXT_KEY: ${{ steps.extract-context.outputs.context_key }}
208226
GH_TOKEN: ${{ github.token }}
209227
GITHUB_REPOSITORY: ${{ github.repository }}
210-
ISSUE_URL: ${{ inputs.issue_url }}
228+
ISSUE_URL: ${{ steps.determine-issue-url.outputs.issue_url }}
211229
TASK_NAME: ${{ steps.create-task.outputs.TASK_NAME }}
212230
run: |
213231
SUMMARY_FILE=$(mktemp)

0 commit comments

Comments
 (0)