fix(sisyphus-agent): prevent bash script breaking on quotes in comment body
Use environment variables instead of direct GitHub expression interpolation in bash script. This prevents the script from breaking when comment bodies contain quotes or special characters.
Variables like COMMENT_BODY, COMMENT_AUTHOR, COMMENT_ID_VAL are now passed via env: block instead of being interpolated directly into bash commands.
🤖 Generated with assistance of OhMyOpenCode
This commit is contained in:
71
.github/workflows/sisyphus-agent.yml
vendored
71
.github/workflows/sisyphus-agent.yml
vendored
@@ -229,39 +229,41 @@ jobs:
|
|||||||
id: context
|
id: context
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
EVENT_NAME: ${{ github.event_name }}
|
||||||
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||||
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
|
COMMENT_BODY: ${{ github.event.comment.body || github.event.review.body }}
|
||||||
|
COMMENT_AUTHOR: ${{ github.event.comment.user.login || github.event.review.user.login }}
|
||||||
|
COMMENT_ID_VAL: ${{ github.event.comment.id }}
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
run: |
|
run: |
|
||||||
EVENT="${{ github.event_name }}"
|
if [[ "$EVENT_NAME" == "issue_comment" ]]; then
|
||||||
|
ISSUE_NUM="$ISSUE_NUMBER"
|
||||||
if [[ "$EVENT" == "issue_comment" ]]; then
|
AUTHOR="$COMMENT_AUTHOR"
|
||||||
ISSUE_NUM="${{ github.event.issue.number }}"
|
COMMENT_ID="$COMMENT_ID_VAL"
|
||||||
COMMENT="${{ github.event.comment.body }}"
|
|
||||||
AUTHOR="${{ github.event.comment.user.login }}"
|
|
||||||
COMMENT_ID="${{ github.event.comment.id }}"
|
|
||||||
|
|
||||||
# Check if PR or Issue
|
# Check if PR or Issue
|
||||||
if gh api "repos/${{ github.repository }}/issues/${ISSUE_NUM}" | jq -e '.pull_request' > /dev/null; then
|
if gh api "repos/$REPO/issues/${ISSUE_NUM}" | jq -e '.pull_request' > /dev/null; then
|
||||||
echo "type=pr" >> $GITHUB_OUTPUT
|
echo "type=pr" >> $GITHUB_OUTPUT
|
||||||
echo "number=${ISSUE_NUM}" >> $GITHUB_OUTPUT
|
echo "number=${ISSUE_NUM}" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "type=issue" >> $GITHUB_OUTPUT
|
echo "type=issue" >> $GITHUB_OUTPUT
|
||||||
echo "number=${ISSUE_NUM}" >> $GITHUB_OUTPUT
|
echo "number=${ISSUE_NUM}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
elif [[ "$EVENT" == "pull_request_review_comment" ]]; then
|
elif [[ "$EVENT_NAME" == "pull_request_review_comment" ]]; then
|
||||||
echo "type=pr" >> $GITHUB_OUTPUT
|
echo "type=pr" >> $GITHUB_OUTPUT
|
||||||
echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
|
echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT
|
||||||
COMMENT="${{ github.event.comment.body }}"
|
AUTHOR="$COMMENT_AUTHOR"
|
||||||
AUTHOR="${{ github.event.comment.user.login }}"
|
COMMENT_ID="$COMMENT_ID_VAL"
|
||||||
COMMENT_ID="${{ github.event.comment.id }}"
|
elif [[ "$EVENT_NAME" == "pull_request_review" ]]; then
|
||||||
elif [[ "$EVENT" == "pull_request_review" ]]; then
|
|
||||||
echo "type=pr" >> $GITHUB_OUTPUT
|
echo "type=pr" >> $GITHUB_OUTPUT
|
||||||
echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
|
echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT
|
||||||
COMMENT="${{ github.event.review.body }}"
|
AUTHOR="$COMMENT_AUTHOR"
|
||||||
AUTHOR="${{ github.event.review.user.login }}"
|
|
||||||
COMMENT_ID=""
|
COMMENT_ID=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "comment<<EOF" >> $GITHUB_OUTPUT
|
echo "comment<<EOF" >> $GITHUB_OUTPUT
|
||||||
echo "$COMMENT" >> $GITHUB_OUTPUT
|
echo "$COMMENT_BODY" >> $GITHUB_OUTPUT
|
||||||
echo "EOF" >> $GITHUB_OUTPUT
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
echo "author=$AUTHOR" >> $GITHUB_OUTPUT
|
echo "author=$AUTHOR" >> $GITHUB_OUTPUT
|
||||||
echo "comment_id=$COMMENT_ID" >> $GITHUB_OUTPUT
|
echo "comment_id=$COMMENT_ID" >> $GITHUB_OUTPUT
|
||||||
@@ -299,27 +301,42 @@ jobs:
|
|||||||
- name: Run oh-my-opencode
|
- name: Run oh-my-opencode
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
USER_COMMENT: ${{ steps.context.outputs.comment }}
|
||||||
|
COMMENT_AUTHOR: ${{ steps.context.outputs.author }}
|
||||||
|
CONTEXT_TYPE: ${{ steps.context.outputs.type }}
|
||||||
|
CONTEXT_NUMBER: ${{ steps.context.outputs.number }}
|
||||||
|
REPO_NAME: ${{ github.repository }}
|
||||||
|
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
||||||
run: |
|
run: |
|
||||||
export PATH="$HOME/.opencode/bin:$PATH"
|
export PATH="$HOME/.opencode/bin:$PATH"
|
||||||
|
|
||||||
PROMPT="
|
PROMPT=$(cat <<'PROMPT_EOF'
|
||||||
Your username is @sisyphus-dev-ai, mentioned by @${{ steps.context.outputs.author }} in ${{ github.repository }}.
|
Your username is @sisyphus-dev-ai, mentioned by @AUTHOR_PLACEHOLDER in REPO_PLACEHOLDER.
|
||||||
|
|
||||||
## Context
|
## Context
|
||||||
- Type: ${{ steps.context.outputs.type }}
|
- Type: TYPE_PLACEHOLDER
|
||||||
- Number: #${{ steps.context.outputs.number }}
|
- Number: #NUMBER_PLACEHOLDER
|
||||||
- Repository: ${{ github.repository }}
|
- Repository: REPO_PLACEHOLDER
|
||||||
- Default Branch: ${{ github.event.repository.default_branch }}
|
- Default Branch: BRANCH_PLACEHOLDER
|
||||||
|
|
||||||
## User's Request
|
## User's Request
|
||||||
${{ steps.context.outputs.comment }}
|
COMMENT_PLACEHOLDER
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
First, acknowledge with \`gh issue comment ${{ steps.context.outputs.number }} --body \"👋 Hey @${{ steps.context.outputs.author }}! I'm on it...\"\`
|
First, acknowledge with `gh issue comment NUMBER_PLACEHOLDER --body "👋 Hey @AUTHOR_PLACEHOLDER! I'm on it..."`
|
||||||
|
|
||||||
Then write everything using the todo tools.
|
Then write everything using the todo tools.
|
||||||
Then investigate and satisfy the request. Only if user requested to you to work explicitely, then use plan agent to plan, todo obsessivley then create a PR to \`${{ github.event.repository.default_branch }}\` branch."
|
Then investigate and satisfy the request. Only if user requested to you to work explicitely, then use plan agent to plan, todo obsessivley then create a PR to `BRANCH_PLACEHOLDER` branch.
|
||||||
|
PROMPT_EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
PROMPT="${PROMPT//AUTHOR_PLACEHOLDER/$COMMENT_AUTHOR}"
|
||||||
|
PROMPT="${PROMPT//REPO_PLACEHOLDER/$REPO_NAME}"
|
||||||
|
PROMPT="${PROMPT//TYPE_PLACEHOLDER/$CONTEXT_TYPE}"
|
||||||
|
PROMPT="${PROMPT//NUMBER_PLACEHOLDER/$CONTEXT_NUMBER}"
|
||||||
|
PROMPT="${PROMPT//BRANCH_PLACEHOLDER/$DEFAULT_BRANCH}"
|
||||||
|
PROMPT="${PROMPT//COMMENT_PLACEHOLDER/$USER_COMMENT}"
|
||||||
|
|
||||||
bun run dist/cli/index.js run "$PROMPT"
|
bun run dist/cli/index.js run "$PROMPT"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user