|
16 | 16 | run: | |
17 | 17 | set -e |
18 | 18 |
|
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" |
25 | 21 | else |
26 | 22 | LABELS="${{ join(github.event.issue.labels.*.name, ',') }}" |
27 | 23 | if [ -n "$LABELS" ] && echo "$LABELS" | grep -q "enhancement"; then |
|
31 | 27 | fi |
32 | 28 | fi |
33 | 29 |
|
| 30 | +
|
34 | 31 | - name: Check if issue already enhanced |
35 | 32 | id: check_enhanced |
36 | 33 | run: | |
@@ -142,41 +139,55 @@ jobs: |
142 | 139 | run: | |
143 | 140 | set -euo pipefail |
144 | 141 |
|
| 142 | + # Ensure jq exists |
145 | 143 | if ! command -v jq >/dev/null; then |
146 | 144 | sudo apt-get update |
147 | 145 | sudo apt-get install -y jq |
148 | 146 | fi |
149 | 147 |
|
| 148 | + # Fetch original issue body (as-is) |
150 | 149 | 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 |
172 | 161 |
|
| 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 |
173 | 180 | curl -X PATCH \ |
174 | 181 | -H "Authorization: token $GITHUB_TOKEN" \ |
175 | 182 | -H "Accept: application/vnd.github+json" \ |
176 | 183 | -H "Content-Type: application/json" \ |
177 | | - -d "$(jq -n --arg body "$BODY" '{body:$body}')" \ |
| 184 | + -d "$(jq -n --arg body "$MARKDOWN" '{body:$body}')" \ |
178 | 185 | "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}" |
179 | 186 |
|
| 187 | + echo "✅ Issue updated with enhanced + original content" |
| 188 | + |
| 189 | + |
| 190 | + |
180 | 191 | add-comment: |
181 | 192 | runs-on: ubuntu-latest |
182 | 193 | needs: update-issue |
|
0 commit comments