Skip to content

Commit 34df8c0

Browse files
authored
Improve GITHUB_STEP_SUMMARY rendering to summary (#15589)
1 parent 2ab655d commit 34df8c0

File tree

1 file changed

+46
-19
lines changed

1 file changed

+46
-19
lines changed

.github/workflows/docs-edit-automation.yml

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,35 @@ jobs:
126126
exit 0
127127
fi
128128
129-
COMMENT="Please run these commands to update changelogs and build docs:\n\nfor pkg in ${PACKAGE_LIST}; do\n cd packages/\$pkg\n elastic-package changelog add --type $CHANGE_TYPE --description \"$CHANGELOG_DESC\" --link \"https://github.com/${{ github.repository }}/pull/$PR_NUMBER\" --next $VERSION_BUMP\n elastic-package build\n cd ../..\ndone\ngit add -u\ngit commit -m \"docs: update changelogs and build documentation\"\ngit push\n\nPrerequisite: \`go install github.com/elastic/elastic-package\`"
129+
COMMENT_FILE=$(mktemp)
130+
{
131+
echo "Please run these commands to update changelogs and build docs:"
132+
echo ""
133+
echo '```bash'
134+
echo "for pkg in ${PACKAGE_LIST}; do"
135+
echo ' cd packages/$pkg'
136+
echo " elastic-package changelog add --type $CHANGE_TYPE --description \"$CHANGELOG_DESC\" --link \"https://github.com/${{ github.repository }}/pull/$PR_NUMBER\" --next $VERSION_BUMP"
137+
echo " elastic-package build"
138+
echo " cd ../.."
139+
echo "done"
140+
echo "git add -u"
141+
echo "git commit -m \"docs: update changelogs and build documentation\""
142+
echo "git push"
143+
echo '```'
144+
echo ""
145+
echo "Prerequisite: \`go install github.com/elastic/elastic-package\`"
146+
} > "$COMMENT_FILE"
130147
131-
# Add info about packages already updated
132148
if [ -n "${{ steps.analyze.outputs.packages_already_done }}" ]; then
133-
COMMENT="$COMMENT\n\nNote: These packages already updated: \`${{ steps.analyze.outputs.packages_already_done }}\`"
149+
echo "" >> "$COMMENT_FILE"
150+
echo "Note: These packages already updated: \`${{ steps.analyze.outputs.packages_already_done }}\`" >> "$COMMENT_FILE"
134151
fi
135-
136-
if ! gh pr comment $PR_NUMBER --body "$COMMENT"; then
152+
153+
if ! gh pr comment "$PR_NUMBER" --body-file "$COMMENT_FILE"; then
137154
{
138155
echo "## 📋 Documentation follow-up"
139156
echo
140-
echo "Unable to post a PR comment (likely due to fork permissions)."
141-
echo
142-
echo "$COMMENT"
157+
cat "$COMMENT_FILE"
143158
} >> "$GITHUB_STEP_SUMMARY"
144159
fi
145160
@@ -158,27 +173,39 @@ jobs:
158173
exit 0
159174
fi
160175
161-
COMMENT="Please run these commands to update changelogs and build docs:\n\nfor pkg in ${PACKAGE_LIST}; do\n cd packages/\$pkg\n elastic-package changelog add --type $CHANGE_TYPE --description \"$CHANGELOG_DESC\" --link \"https://github.com/${{ github.repository }}/pull/$PR_NUMBER\" --next $VERSION_BUMP\n elastic-package build\n cd ../..\ndone\ngit add -u\ngit commit -m \"docs: update changelogs and build documentation\"\ngit push\n\nPrerequisite: \`go install github.com/elastic/elastic-package\`"
162-
163-
if [ -n "${{ steps.analyze.outputs.packages_already_done }}" ]; then
164-
COMMENT="$COMMENT\n\nNote: These packages already updated: \`${{ steps.analyze.outputs.packages_already_done }}\`"
165-
fi
166-
167176
{
168177
echo "## 📋 Documentation follow-up"
169-
echo
170-
echo "$COMMENT"
178+
echo ""
179+
echo "Please run these commands to update changelogs and build docs:"
180+
echo ""
181+
echo '```bash'
182+
echo "for pkg in ${PACKAGE_LIST}; do"
183+
echo ' cd packages/$pkg'
184+
echo " elastic-package changelog add --type $CHANGE_TYPE --description \"$CHANGELOG_DESC\" --link \"https://github.com/${{ github.repository }}/pull/$PR_NUMBER\" --next $VERSION_BUMP"
185+
echo " elastic-package build"
186+
echo " cd ../.."
187+
echo "done"
188+
echo "git add -u"
189+
echo "git commit -m \"docs: update changelogs and build documentation\""
190+
echo "git push"
191+
echo '```'
192+
echo ""
193+
echo "Prerequisite: \`go install github.com/elastic/elastic-package\`"
194+
if [ -n "${{ steps.analyze.outputs.packages_already_done }}" ]; then
195+
echo ""
196+
echo "Note: These packages already updated: \`${{ steps.analyze.outputs.packages_already_done }}\`"
197+
fi
171198
} >> "$GITHUB_STEP_SUMMARY"
172199
173200
- name: Add labels
174201
run: |
175-
echo "Please add the following labels — '${{ steps.analyze.outputs.label }}' and 'documentation'"
202+
echo "Please add the following labels — '${{ steps.analyze.outputs.label }}' and 'documentation'" >> "$GITHUB_STEP_SUMMARY"
176203
177204
- name: Handle edge cases
178205
if: steps.analyze.outputs.no_docs_changes == 'true' || (steps.analyze.outputs.packages_needing_update == '' && steps.analyze.outputs.packages_already_done != '')
179206
run: |
180207
if [ "${{ steps.analyze.outputs.no_docs_changes }}" = "true" ]; then
181-
MESSAGE="No documentation files (\`packages/*/_dev/build/docs/README.md\`) were changed in this PR."
208+
MESSAGE="No documentation files (packages/*/_dev/build/docs/README.md) were changed in this PR."
182209
else
183210
MESSAGE="All packages with documentation changes already have updated changelogs and manifests."
184211
fi
@@ -187,4 +214,4 @@ jobs:
187214
188215
$MESSAGE
189216
190-
Your PR is ready for review! 🎉"
217+
Your PR is ready for review! 🎉" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)