Skip to content

Commit 8c370da

Browse files
authored
Improve enhancement label handling and issue update
Refactor enhancement label check and update issue body formatting.
1 parent 34d040e commit 8c370da

1 file changed

Lines changed: 39 additions & 28 deletions

File tree

.github/workflows/feature-request-enhance.yml

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ jobs:
1616
run: |
1717
set -e
1818
19-
if [ "${{ github.event.action }}" = "labeled" ]; then
20-
if [ "${{ github.event.label.name }}" = "enhancement" ]; then
21-
echo "has_enhancement=true" >> "$GITHUB_OUTPUT"
22-
else
23-
echo "has_enhancement=false" >> "$GITHUB_OUTPUT"
24-
fi
19+
if [ "${{ github.event.action }}" = "labeled" ] && [ "${{ github.event.label.name }}" = "enhancement" ]; then
20+
echo "has_enhancement=true" >> "$GITHUB_OUTPUT"
2521
else
2622
LABELS="${{ join(github.event.issue.labels.*.name, ',') }}"
2723
if [ -n "$LABELS" ] && echo "$LABELS" | grep -q "enhancement"; then
@@ -31,6 +27,7 @@ jobs:
3127
fi
3228
fi
3329
30+
3431
- name: Check if issue already enhanced
3532
id: check_enhanced
3633
run: |
@@ -142,41 +139,55 @@ jobs:
142139
run: |
143140
set -euo pipefail
144141
142+
# Ensure jq exists
145143
if ! command -v jq >/dev/null; then
146144
sudo apt-get update
147145
sudo apt-get install -y jq
148146
fi
149147
148+
# Fetch original issue body (as-is)
150149
ORIGINAL=$(curl -s \
151-
-H "Authorization: token $GITHUB_TOKEN" \
152-
-H "Accept: application/vnd.github+json" \
153-
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}" \
154-
| jq -r '.body // ""')
155-
156-
BODY=$(jq -n \
157-
--arg enhanced "$ENHANCED" \
158-
--arg original "$ORIGINAL" \
159-
--arg confluence "$CONFLUENCE_URL" \
160-
--arg requester "${{ github.event.issue.user.login }}" \
161-
--arg created "${{ github.event.issue.created_at }}" \
162-
'"## 📝 Enhanced Feature Request\n\n"
163-
+ $enhanced
164-
+ "\n\n---\n\n📄 **Requirements documented:** "
165-
+ $confluence
166-
+ "\n\n---\n\n## 📋 Original Request\n\n"
167-
+ $original
168-
+ "\n\n---\n\n**Requested by:** "
169-
+ $requester
170-
+ "\n**Created:** "
171-
+ $created')
150+
-H "Authorization: token $GITHUB_TOKEN" \
151+
-H "Accept: application/vnd.github+json" \
152+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}" \
153+
| jq -r '.body | split("## 📝 Enhanced Feature Request")[0] // ""')
154+
155+
156+
# Build Markdown body (NO escaped \n, real newlines)
157+
MARKDOWN=$(cat <<EOF
158+
## 📝 Enhanced Feature Request
159+
160+
$ENHANCED
172161

162+
---
163+
164+
📄 **Requirements documented:** ${CONFLUENCE_URL:-_Not available_}
165+
166+
---
167+
168+
## 📋 Original Request
169+
170+
$ORIGINAL
171+
172+
---
173+
174+
**Requested by:** ${{ github.event.issue.user.login }}
175+
**Created:** ${{ github.event.issue.created_at }}
176+
EOF
177+
)
178+
179+
# Update the issue
173180
curl -X PATCH \
174181
-H "Authorization: token $GITHUB_TOKEN" \
175182
-H "Accept: application/vnd.github+json" \
176183
-H "Content-Type: application/json" \
177-
-d "$(jq -n --arg body "$BODY" '{body:$body}')" \
184+
-d "$(jq -n --arg body "$MARKDOWN" '{body:$body}')" \
178185
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}"
179186

187+
echo "✅ Issue updated with enhanced + original content"
188+
189+
190+
180191
add-comment:
181192
runs-on: ubuntu-latest
182193
needs: update-issue

0 commit comments

Comments
 (0)