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

Commit068264d

Browse files
committed
ci(.github/workflows/traiage.yaml): use create-task-action
1 parent7dc7563 commit068264d

File tree

1 file changed

+46
-72
lines changed

1 file changed

+46
-72
lines changed

‎.github/workflows/traiage.yaml‎

Lines changed: 46 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ on:
1717
type:string
1818
template_preset:
1919
description:"Template preset to use"
20-
required:true
21-
default:"none"
20+
required:false
21+
default:""
2222
type:string
2323
prefix:
2424
description:"Prefix for workspace name"
@@ -67,7 +67,7 @@ jobs:
6767
GITHUB_EVENT_USER_LOGIN:${{ github.event.sender.login }}
6868
INPUTS_ISSUE_URL:${{ inputs.issue_url }}
6969
INPUTS_TEMPLATE_NAME:${{ inputs.template_name || 'coder' }}
70-
INPUTS_TEMPLATE_PRESET:${{ inputs.template_preset || 'none'}}
70+
INPUTS_TEMPLATE_PRESET:${{ inputs.template_preset || ''}}
7171
INPUTS_PREFIX:${{ inputs.prefix || 'traiage' }}
7272
GH_TOKEN:${{ github.token }}
7373
run:|
@@ -124,94 +124,68 @@ jobs:
124124
exit 1
125125
fi
126126
127-
-name:Extract context key from issue
127+
-name:Extract context keyand descriptionfrom issue
128128
id:extract-context
129129
env:
130130
ISSUE_URL:${{ steps.determine-inputs.outputs.issue_url }}
131131
GH_TOKEN:${{ github.token }}
132132
run:|
133133
issue_number="$(gh issue view "${ISSUE_URL}" --json number --jq '.number')"
134134
context_key="gh-${issue_number}"
135-
echo "context_key=${context_key}" >> "${GITHUB_OUTPUT}"
136-
echo "CONTEXT_KEY=${context_key}" >> "${GITHUB_ENV}"
137-
138-
-name:Download and install Coder binary
139-
shell:bash
140-
env:
141-
CODER_URL:${{ secrets.TRAIAGE_CODER_URL }}
142-
run:|
143-
if [ "${{ runner.arch }}" == "ARM64" ]; then
144-
ARCH="arm64"
145-
else
146-
ARCH="amd64"
147-
fi
148-
mkdir -p "${HOME}/.local/bin"
149-
curl -fsSL --compressed "$CODER_URL/bin/coder-linux-${ARCH}" -o "${HOME}/.local/bin/coder"
150-
chmod +x "${HOME}/.local/bin/coder"
151-
export PATH="$HOME/.local/bin:$PATH"
152-
coder version
153-
coder whoami
154-
echo "$HOME/.local/bin" >> "${GITHUB_PATH}"
155-
156-
-name:Get Coder username from GitHub actor
157-
id:get-coder-username
158-
env:
159-
CODER_SESSION_TOKEN:${{ secrets.TRAIAGE_CODER_SESSION_TOKEN }}
160-
GH_TOKEN:${{ github.token }}
161-
GITHUB_USER_ID:${{ steps.determine-inputs.outputs.github_user_id }}
162-
run:|
163-
user_json=$(
164-
coder users list --github-user-id="${GITHUB_USER_ID}" --output=json
165-
)
166-
coder_username=$(jq -r 'first | .username' <<< "$user_json")
167-
[[ -z "${coder_username}" || "${coder_username}" == "null" ]] && echo "No Coder user with GitHub user ID ${GITHUB_USER_ID} found" && exit 1
168-
echo "coder_username=${coder_username}" >> "${GITHUB_OUTPUT}"
169-
170-
-name:Checkout repository
171-
uses:actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8# v5.0.0
172-
with:
173-
persist-credentials:false
174-
fetch-depth:0
175135
176-
# TODO(Cian): this is a good use-case for 'recipes'
177-
-name:Create Coder task
178-
id:create-task
179-
env:
180-
CODER_USERNAME:${{ steps.get-coder-username.outputs.coder_username }}
181-
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
182-
GH_TOKEN:${{ github.token }}
183-
GITHUB_REPOSITORY:${{ github.repository }}
184-
ISSUE_URL:${{ steps.determine-inputs.outputs.issue_url }}
185-
PREFIX:${{ steps.determine-inputs.outputs.prefix }}
186-
RUN_ID:${{ github.run_id }}
187-
TEMPLATE_NAME:${{ steps.determine-inputs.outputs.template_name }}
188-
TEMPLATE_PARAMETERS:${{ secrets.TRAIAGE_TEMPLATE_PARAMETERS }}
189-
TEMPLATE_PRESET:${{ steps.determine-inputs.outputs.template_preset }}
190-
run:|
191136
# Fetch issue description using `gh` CLI
192137
#shellcheck disable=SC2016 # The template string should not be subject to shell expansion
193138
issue_description=$(gh issue view "${ISSUE_URL}" \
194139
--json 'title,body,comments' \
195140
--template '{{printf "%s\n\n%s\n\nComments:\n" .title .body}}{{range $k, $v := .comments}} - {{index $v.author "login"}}: {{printf "%s\n" $v.body}}{{end}}')
196141
197-
# Write a prompt to PROMPT_FILE
198-
PROMPT=$(cat <<EOF
142+
TASK_PROMPT=$(cat <<EOF
199143
Fix ${ISSUE_URL}
200144
201145
Analyze the below GitHub issue description, understand the root cause, and make appropriate changes to resolve the issue.
202146
---
203147
${issue_description}
204148
EOF
205149
)
206-
export PROMPT
207150
208-
export TASK_NAME="${PREFIX}-${CONTEXT_KEY}-${RUN_ID}"
209-
echo "Creating task: $TASK_NAME"
210-
./scripts/traiage.sh create
211-
if [[ "${ISSUE_URL}" == "https://github.com/${GITHUB_REPOSITORY}"* ]]; then
212-
gh issue comment "${ISSUE_URL}" --body "Task created: https://dev.coder.com/tasks/${CODER_USERNAME}/${TASK_NAME}" --create-if-none --edit-last
213-
else
214-
echo "Skipping comment on other repo."
215-
fi
216-
echo "TASK_NAME=${CODER_USERNAME}/${TASK_NAME}" >> "${GITHUB_OUTPUT}"
217-
echo "TASK_NAME=${CODER_USERNAME}/${TASK_NAME}" >> "${GITHUB_ENV}"
151+
echo "context_key=${context_key}" >> "${GITHUB_OUTPUT}"
152+
{
153+
echo "TASK_PROMPT<<EOF"
154+
echo "${TASK_PROMPT}"
155+
echo "EOF"
156+
} >> "${GITHUB_OUTPUT}"
157+
158+
-name:Checkout repository
159+
uses:actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8# v5.0.0
160+
with:
161+
persist-credentials:false
162+
fetch-depth:1
163+
164+
-name:Create Coder Task
165+
id:create_task
166+
# TODO: remove manual vendoring when repo is public
167+
uses:./.github/actions/create-task-action
168+
with:
169+
coder-url:${{ secrets.TRAIAGE_CODER_URL }}
170+
coder-token:${{ secrets.TRAIAGE_CODER_SESSION_TOKEN }}
171+
coder-organization:"default"
172+
coder-template-name:coder
173+
coder-template-preset:${{ steps.determine-inputs.outputs.template_preset }}
174+
coder-task-name-prefix:traiage
175+
coder-task-prompt:${{ steps.extract-context.outputs.task_prompt }}
176+
github-user-id:${{ steps.determine-inputs.outputs.github_user_id }}
177+
github-token:${{ github.token }}
178+
github-issue-url:${{ steps.determine-inputs.outputs.issue_url }}
179+
comment-on-issue:${{ startsWith(steps.determine-inputs.outputs.issue_url, format('{0}/{1}', github.server_url, github.repository)) }}
180+
181+
-name:Write outputs
182+
env:
183+
TASK_CREATED:${{ steps.create_task.outputs.task-created }}
184+
TASK_NAME:${{ steps.create_task.outputs.task-name }}
185+
TASK_URL:${{ steps.create_task.outputs.task-url }}
186+
run:|
187+
{
188+
echo "**Task created:** ${TASK_CREATED}"
189+
echo "**Task name:** ${TASK_NAME}"
190+
echo "**Task URL**: ${TASK_URL}"
191+
} >> "${GITHUB_STEP_SUMMARY}"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp