Skip to content

Commit 33a0b4e

Browse files
authored
Modify permissions and enhance Slack notification logic
Updated permissions for contents and improved task handling in Slack notification.
1 parent 03dda0b commit 33a0b4e

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/aicode-preprocess.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
preprocess:
99
runs-on: ubuntu-latest
1010
permissions:
11-
contents: read
11+
contents: write
1212
actions: write
1313

1414
steps:
@@ -135,10 +135,24 @@ jobs:
135135
if: always()
136136
run: |
137137
if [ "${{ steps.preprocess.outcome }}" == "success" ]; then
138-
# Use jq to properly construct JSON payload with proper escaping
139-
ORIGINAL_TASK="${{ github.event.client_payload.task }}"
140-
ENHANCED_TASK="${{ steps.preprocess.outputs.enhanced_task }}"
138+
# Read from JSON file to avoid shell quoting issues
139+
if [ -f /tmp/task_json.json ] && jq -e . /tmp/task_json.json >/dev/null 2>&1; then
140+
# Read from JSON file (safest method)
141+
ORIGINAL_TASK=$(jq -r '.original // empty' /tmp/task_json.json)
142+
ENHANCED_TASK=$(jq -r '.enhanced // empty' /tmp/task_json.json)
143+
else
144+
# Fallback: read original from event, enhanced from file if available
145+
ORIGINAL_TASK="${{ github.event.client_payload.task }}"
146+
# Try to read enhanced_task from file, or use a safe default
147+
if [ -f /tmp/task_json.json ]; then
148+
ENHANCED_TASK=$(jq -r '.enhanced // empty' /tmp/task_json.json || echo "$ORIGINAL_TASK")
149+
else
150+
# Last resort: use original task as enhanced (better than breaking)
151+
ENHANCED_TASK="$ORIGINAL_TASK"
152+
fi
153+
fi
141154
155+
# Use jq to properly construct JSON payload with proper escaping
142156
PAYLOAD=$(jq -n \
143157
--arg text "📝 Task preprocessed and enhanced. Triggering code generation..." \
144158
--arg original "$ORIGINAL_TASK" \

0 commit comments

Comments
 (0)