9
9
type :string
10
10
context_key :
11
11
description :' Unique context key (defaults to issue number)'
12
- required :false
12
+ required :true
13
13
type :string
14
14
template_name :
15
15
description :' Coder template to use for workspace'
16
- required :false
16
+ required :true
17
17
default :' ai-workspace'
18
18
type :string
19
19
20
- env :
21
- CODER_URL :${{ secrets.CODER_URL }}
22
- CODER_SESSION_TOKEN :${{ secrets.CODER_SESSION_TOKEN }}
23
- TEMPLATE_NAME :${{ inputs.template_name }}
24
20
25
21
jobs :
26
22
triage :
27
- name :AI TriageProcessing
23
+ name :TriageGitHub Issue with Claude Code
28
24
runs-on :ubuntu-latest
29
25
timeout-minutes :30
26
+ env :
27
+ CODER_URL :${{ secrets.CODER_URL }}
28
+ CODER_SESSION_TOKEN :${{ secrets.CODER_SESSION_TOKEN }}
29
+ TEMPLATE_NAME :${{ inputs.template_name }}
30
30
31
31
steps :
32
32
-name :Checkout repository
33
33
uses :actions/checkout@v4
34
34
35
- -name :Install Coder CLI
36
- uses :coder/setup-coder@latest
35
+ # NOTE: Only required for local testing via nektos/act
36
+ # - name: Install gh CLI
37
+ # run: |
38
+ # sudo apt-get update -y && \
39
+ # sudo apt-get install -y gh && \
40
+ # gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
37
41
38
- -name :Extract context key from issue URL
39
- id :extract-context
42
+ -name :Download and install Coder binary
43
+ shell :bash
44
+ env :
45
+ CODER_URL :${{ secrets.CODER_URL }}
40
46
run :|
41
- if [[ -n "${{inputs.context_key }}"] ]; then
42
- echo "context_key=${{ inputs.context_key }}" >> $GITHUB_OUTPUT
47
+ if [ "${{runner.arch }}"== "ARM64" ]; then
48
+ ARCH="arm64"
43
49
else
44
- # Extract issue number from URL (e.g., https://github.com/owner/repo/issues/123 -> 123)
45
- issue_number=$(echo "${{ inputs.issue_url }}" | grep -oE '/issues/([0-9]+)' | grep -oE '[0-9]+')
46
- echo "context_key=issue_${issue_number}" >> $GITHUB_OUTPUT
50
+ ARCH="amd64"
47
51
fi
48
-
49
- # Generate unique workspace name
50
- timestamp=$(date +%s)
51
- workspace_name="triage-$(echo "${{ inputs.context_key || 'auto' }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g')-${timestamp}"
52
- echo "workspace_name=${workspace_name}" >> $GITHUB_OUTPUT
52
+ mkdir -p "$HOME"/.local/bin
53
+ curl -fsSL --compressed "$CODER_URL"/bin/coder-linux-${ARCH} -o "$HOME"/.local/bin/coder
54
+ chmod +x "$HOME"/.local/bin/coder
55
+ echo "$HOME/.local/bin" >> $GITHUB_PATH
56
+ "$HOME"/.local/bin/coder version
57
+ "$HOME"/.local/bin/coder whoami
53
58
54
59
-name :Create Coder workspace
55
60
id :create-workspace
56
- env :
57
- WORKSPACE_NAME :${{ steps.extract-context.outputs.workspace_name }}
58
61
run :|
62
+ export WORKSPACE_NAME="gh-issue-${{ inputs.context_key }}-${{ github.run_id }}"
59
63
echo "Creating workspace: $WORKSPACE_NAME"
60
64
./scripts/traiage.sh create
61
65
echo "workspace_created=true" >> $GITHUB_OUTPUT
66
+ echo "workspace_name=$WORKSPACE_NAME" >> $GITHUB_OUTPUT
67
+ echo "WORKSPACE_NAME=${WORKSPACE_NAME}" >> $GITHUB_ENV
62
68
63
- -name :Prepare AIprompt
69
+ -name :Send prompt to AIagent inside workspace
64
70
id :prepare-prompt
65
71
run :|
72
+ PROMPT_FILE=/tmp/prompt.txt
73
+ trap 'rm -f ${PROMPT_FILE}' EXIT
74
+
66
75
# Extract issue content and prepare prompt
67
76
issue_url="${{ inputs.issue_url }}"
68
77
context_key="${{ steps.extract-context.outputs.context_key }}"
69
78
70
- #Create a prompt that includes the issueURL and context
71
- prompt="Process GitHub issue: ${issue_url}. Context key: ${context_key}. Please analyze the issue, understand the requirements, and create appropriate solutions."
79
+ #Fetch issuedescription using `gh` CLI
80
+ issue_description=$(gh issue view "$issue_url")
72
81
73
- #Escape the promptfor shell usage
74
- escaped_prompt=$(printf '%s\n' "$prompt" | sed 's/[\[\](){}.*^$+?|\\]/\\&/g')
75
- echo "prompt=${escaped_prompt}" >> $GITHUB_OUTPUT
82
+ #Write a promptto PROMPT_FILE
83
+ cat > "${PROMPT_FILE}" <<EOF
84
+ Analyze the below GitHub issue description, understand the root cause, and make appropriate changes to resolve the issue.
76
85
77
- - name : Execute AI processing
78
- id : ai-process
79
- env :
80
- WORKSPACE_NAME : ${{ steps.extract-context.outputs.workspace_name } }
81
- PROMPT : ${{ steps.prepare-prompt.outputs.prompt }}
82
- run : |
83
- echo "Sending prompt to AI agent in workspace : $WORKSPACE_NAME"
84
- ./scripts/traiage.sh prompt
86
+ ISSUE URL: ${issue_url}
87
+ ISSUE DESCRIPTION BELOW:
88
+
89
+ ${issue_description }
90
+ EOF
91
+
92
+ echo "WORKSPACE_NAME : ${ WORKSPACE_NAME} "
93
+ PROMPT=$(cat $PROMPT_FILE) ./scripts/traiage.sh prompt
85
94
86
95
-name :Create and upload archive
87
96
id :create-archive
88
- env :
89
- WORKSPACE_NAME :${{ steps.extract-context.outputs.workspace_name }}
90
97
run :|
91
98
echo "Creating archive for workspace: $WORKSPACE_NAME"
92
99
archive_url=$(./scripts/traiage.sh archive)
@@ -102,8 +109,6 @@ jobs:
102
109
103
110
-name :Cleanup workspace
104
111
if :always() && steps.create-workspace.outputs.workspace_created == 'true'
105
- env :
106
- WORKSPACE_NAME :${{ steps.extract-context.outputs.workspace_name }}
107
112
run :|
108
113
echo "Cleaning up workspace: $WORKSPACE_NAME"
109
114
./scripts/traiage.sh delete ||true