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

Commitedd9746

Browse files
johnstcnmafredri
andauthored
ci: assign tasks to triggering username in ai triage workflow (#20022)
Note: this requires owner-level perms on the token. This can be removed once it becomes possible to search org members by GitHub ID without owner-level perms.---------Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
1 parentec417de commitedd9746

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

‎.github/workflows/traiage.yaml‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,27 @@ jobs:
7373
coder whoami
7474
echo "$HOME/.local/bin" >> "${GITHUB_PATH}"
7575
76+
-name:Get Coder username from GitHub actor
77+
id:get-coder-username
78+
env:
79+
CODER_SESSION_TOKEN:${{ secrets.TRAIAGE_CODER_SESSION_TOKEN }}
80+
GITHUB_USER_ID:${{
81+
(github.event_name == 'workflow_dispatch' && github.actor_id)
82+
}}
83+
run:|
84+
[[ -z "${GITHUB_USER_ID}" || "${GITHUB_USER_ID}" == "null" ]] && echo "No GitHub actor ID found" && exit 1
85+
user_json=$(
86+
coder users list --github-user-id="${GITHUB_USER_ID}" --output=json
87+
)
88+
coder_username=$(jq -r 'first | .username' <<< "$user_json")
89+
[[ -z "${coder_username}" || "${coder_username}" == "null" ]] && echo "No Coder user with GitHub user ID ${GITHUB_USER_ID} found" && exit 1
90+
echo "coder_username=${coder_username}" >> "${GITHUB_OUTPUT}"
91+
7692
# TODO(Cian): this is a good use-case for 'recipes'
7793
-name:Create Coder task
7894
id:create-task
7995
env:
96+
CODER_USERNAME:${{ steps.get-coder-username.outputs.coder_username }}
8097
CONTEXT_KEY:${{ steps.extract-context.outputs.context_key }}
8198
GITHUB_TOKEN:${{ github.token }}
8299
ISSUE_URL:${{ inputs.issue_url }}
@@ -103,9 +120,9 @@ jobs:
103120
export TASK_NAME="${PREFIX}-${CONTEXT_KEY}-${RUN_ID}"
104121
echo "Creating task: $TASK_NAME"
105122
./scripts/traiage.sh create
106-
coder exp task status "$TASK_NAME" --watch
107-
echo "TASK_NAME=${TASK_NAME}" >> "${GITHUB_OUTPUT}"
108-
echo "TASK_NAME=${TASK_NAME}" >> "${GITHUB_ENV}"
123+
coder exp task status "${CODER_USERNAME}/$TASK_NAME" --watch
124+
echo "TASK_NAME=${CODER_USERNAME}/${TASK_NAME}" >> "${GITHUB_OUTPUT}"
125+
echo "TASK_NAME=${CODER_USERNAME}/${TASK_NAME}" >> "${GITHUB_ENV}"
109126
110127
-name:Create and upload archive
111128
id:create-archive

‎scripts/traiage.sh‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ usage() {
1919
}
2020

2121
create() {
22-
requiredenvs CODER_URL CODER_SESSION_TOKEN TASK_NAME TEMPLATE_NAME TEMPLATE_PRESET PROMPT
22+
requiredenvs CODER_URL CODER_SESSION_TOKENCODER_USERNAMETASK_NAME TEMPLATE_NAME TEMPLATE_PRESET PROMPT
2323
# Check if a task already exists
2424
set +e
2525
task_json=$("${CODER_BIN}" \
2626
--url"${CODER_URL}" \
2727
--token"${CODER_SESSION_TOKEN}" \
28-
exp tasks status"${TASK_NAME}" \
28+
exp tasks status"${CODER_USERNAME}/${TASK_NAME}" \
2929
--output json)
3030
set -e
3131

3232
if [["${TASK_NAME}"==$(jq -r'.name'<<<"${task_json}") ]];then
33-
echo"Task\"${TASK_NAME}\" already exists. Sending prompt to existing task."
33+
echo"Task\"${CODER_USERNAME}/${TASK_NAME}\" already exists. Sending prompt to existing task."
3434
prompt
3535
exit 0
3636
fi
@@ -43,6 +43,7 @@ create() {
4343
--template"${TEMPLATE_NAME}" \
4444
--preset"${TEMPLATE_PRESET}" \
4545
--org coder \
46+
--owner"${CODER_USERNAME}" \
4647
--stdin<<<"${PROMPT}"
4748
exit 0
4849
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp