Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f3e03a

Browse files
authored
ci: add auto-generated summary and GitHub issue comment workflows to triage.yaml (#19925)
1 parent77d19c9 commit8f3e03a

File tree

2 files changed

+83
-23
lines changed

2 files changed

+83
-23
lines changed

‎.github/workflows/traiage.yaml‎

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ on:
44
workflow_dispatch:
55
inputs:
66
issue_url:
7-
description:'GitHub Issue URL to process'
7+
description:"GitHub Issue URL to process"
88
required:true
99
type:string
1010
template_name:
11-
description:'Coder template to use for workspace'
11+
description:"Coder template to use for workspace"
1212
required:true
13-
default:'traiage'
13+
default:"traiage"
1414
type:string
1515
prefix:
16-
description:'Prefix for workspace name'
16+
description:"Prefix for workspace name"
1717
required:false
18-
default:'traiage'
18+
default:"traiage"
1919
type:string
2020

2121
jobs:
@@ -89,7 +89,7 @@ jobs:
8989
ISSUE_URL:${{ inputs.issue_url }}
9090
GITHUB_TOKEN:${{ github.token }}
9191
run:|
92-
PROMPT_FILE=/tmp/prompt.txt
92+
PROMPT_FILE=$(mktemp)
9393
trap 'rm -f "${PROMPT_FILE}"' EXIT
9494
9595
# Fetch issue description using `gh` CLI
@@ -108,7 +108,7 @@ jobs:
108108
echo "WORKSPACE_NAME: ${WORKSPACE_NAME}"
109109
# This command will run the prompt inside the workspace
110110
# and exit once the agent has completed the task.
111-
PROMPT=$(cat$PROMPT_FILE) ./scripts/traiage.sh prompt
111+
PROMPT=$(cat"${PROMPT_FILE}") ./scripts/traiage.sh prompt
112112
113113
-name:Create and upload archive
114114
id:create-archive
@@ -119,27 +119,43 @@ jobs:
119119
./scripts/traiage.sh archive
120120
echo "archive_url=${BUCKET_PREFIX%%/}/$WORKSPACE_NAME.tar.gz" >> "${GITHUB_OUTPUT}"
121121
122-
-name:Report results
122+
-name:Generate a summary of the changes and post a comment on GitHub.
123+
id:generate-summary
123124
env:
124-
ISSUE_URL:${{ inputs.issue_url }}
125-
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
126-
WORKSPACE_NAME:${{ steps.create-workspace.outputs.workspace_name }}
127125
ARCHIVE_URL:${{ steps.create-archive.outputs.archive_url }}
128126
BUCKET_PREFIX:"gs://coder-traiage-outputs/traiage"
127+
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
128+
GITHUB_TOKEN:${{ github.token }}
129+
GITHUB_REPOSITORY:${{ github.repository }}
130+
ISSUE_URL:${{ inputs.issue_url }}
131+
WORKSPACE_NAME:${{ steps.create-workspace.outputs.workspace_name }}
129132
run:|
133+
SUMMARY_FILE=$(mktemp)
134+
trap 'rm -f "${SUMMARY_FILE}"' EXIT
135+
AUTO_SUMMARY=$(./scripts/traiage.sh summary)
130136
{
131-
echo "## TrAIage Results";
132-
echo "- **Issue URL:** ${ISSUE_URL}";
133-
echo "- **Context Key:** ${CONTEXT_KEY}";
134-
echo "- **Workspace:** ${WORKSPACE_NAME}";
135-
echo "- **Archive URL:** ${ARCHIVE_URL}";
136-
137-
echo "To fetch the output to your own workspace:";
138-
echo '';
139-
echo '```bash';
140-
echo "BUCKET_PREFIX=${BUCKET_PREFIX} WORKSPACE_NAME=${WORKSPACE_NAME} ./scripts/traiage.sh resume";
137+
echo "## TrAIage Results"
138+
echo "- **Issue URL:** ${ISSUE_URL}"
139+
echo "- **Context Key:** ${CONTEXT_KEY}"
140+
echo "- **Workspace:** ${WORKSPACE_NAME}"
141+
echo "- **Archive URL:** ${ARCHIVE_URL}"
142+
echo
143+
echo "${AUTO_SUMMARY}"
144+
echo
145+
echo "To fetch the output to your own workspace:"
146+
echo
147+
echo '```bash'
148+
echo "BUCKET_PREFIX=${BUCKET_PREFIX} WORKSPACE_NAME=${WORKSPACE_NAME} ./scripts/traiage.sh resume"
141149
echo '```'
142-
} >> "${GITHUB_STEP_SUMMARY}"
150+
echo
151+
} >> "${SUMMARY_FILE}"
152+
153+
if [[ "${ISSUE_URL}" == "https://github.com/${GITHUB_REPOSITORY}"* ]]; then
154+
gh issue comment "${ISSUE_URL}" --body-file "${SUMMARY_FILE}" --create-if-none --edit-last
155+
else
156+
echo "Skipping comment on other repo."
157+
fi
158+
cat "${SUMMARY_FILE}" >> "${GITHUB_STEP_SUMMARY}"
143159
144160
-name:Cleanup workspace
145161
if:steps.create-workspace.outputs.workspace_name != '' && steps.create-archive.outputs.archive_url != ''

‎scripts/traiage.sh‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ usage() {
2020

2121
create() {
2222
requiredenvs CODER_URL CODER_SESSION_TOKEN WORKSPACE_NAME TEMPLATE_NAME TEMPLATE_PARAMETERS
23+
# Check if a workspace already exists
24+
exists=$("${CODER_BIN}" \
25+
--url"${CODER_URL}" \
26+
--token"${CODER_SESSION_TOKEN}" \
27+
list \
28+
--search"owner:me" \
29+
--output json|
30+
jq -r --arg name"${WORKSPACE_NAME}"'any(.[]; select(.name == $name))')
31+
if [["${exists}"=="true" ]];then
32+
echo"Workspace${WORKSPACE_NAME} already exists."
33+
exit 0
34+
fi
2335
"${CODER_BIN}" \
2436
--url"${CODER_URL}" \
2537
--token"${CODER_SESSION_TOKEN}" \
@@ -54,7 +66,8 @@ ssh_config() {
5466
--url"${CODER_URL}" \
5567
--token"${CODER_SESSION_TOKEN}" \
5668
--ssh-config-file="${OPENSSH_CONFIG_FILE}" \
57-
--yes
69+
--yes \
70+
>/dev/null2>&1
5871
export OPENSSH_CONFIG_FILE
5972
}
6073

@@ -169,6 +182,34 @@ archive() {
169182
exit 0
170183
}
171184

185+
summary() {
186+
requiredenvs CODER_URL CODER_SESSION_TOKEN WORKSPACE_NAME
187+
ssh_config
188+
189+
# We want the heredoc to be expanded locally and not remotely.
190+
# shellcheck disable=SC2087
191+
ssh \
192+
-F"${OPENSSH_CONFIG_FILE}" \
193+
"${WORKSPACE_NAME}.coder" \
194+
-- \
195+
bash<<-EOF
196+
#!/usr/bin/env bash
197+
set -eu
198+
summary=\$(echo -n 'You are a CLI utility that generates a human-readable Markdown summary for the currently staged AND unstaged changes. Print ONLY the summary and nothing else.' |\${HOME}/.local/bin/claude --print)
199+
if [[ -z "\${summary}" ]]; then
200+
echo "Generating a summary failed."
201+
echo "Here is a short overview of the changes:"
202+
echo
203+
echo ""
204+
echo "\$(git diff --stat)"
205+
echo ""
206+
exit 0
207+
fi
208+
echo "\${summary}"
209+
exit 0
210+
EOF
211+
}
212+
172213
commit_push() {
173214
requiredenvs CODER_URL CODER_SESSION_TOKEN WORKSPACE_NAME
174215
ssh_config
@@ -265,6 +306,9 @@ main() {
265306
resume)
266307
resume
267308
;;
309+
summary)
310+
summary
311+
;;
268312
*)
269313
echo"Unknown option:$1"
270314
usage

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp