Feature Request: Idempotent append mode with configurable markers
Problem Statement
When using the append update strategy, repeated runs of the GitHub Action (e.g., due to workflow re-execution) can result in duplicate additions to the same comment. This leads to bloated comments and unnecessary redundancy in CI/CD logs, summaries, or automated reports.
Additionally, when multiple workflows modify the same comment, their append operations might interfere with each other.
Proposed Solution
Introduce a marker-based append mode where appended content is enclosed within identifiable markers, allowing control over how subsequent additions behave. This system ensures idempotency and prevents duplication while allowing multiple workflows to operate independently.
Looking forward to your thoughts on this! Thanks for your great work on the project.
1. Configurable Marked Append Blocks
- Use a marker format:
<!-- peter-evans/create-or-update-comment:append-marker-start:CONFIGURABLE_TEXT --> content... <!-- peter-evans/create-or-update-comment:append-marker-end:CONFIGURABLE_TEXT --> - The
CONFIGURABLE_TEXTpart is set by the user (e.g.,workflow-build-summary,lint-results). - Before appending, the action checks if a block with the same marker exists.
2. Configurable Behavior (append-mode)
-
append-mode: replace→ Replace the last appended block with the new content. -
append-mode: add-after→ Append new content after the last appended block, enlarging markers in the process.
Example Usage
Initial Append:
steps:
- uses: peter-evans/create-or-update-comment@v4
with:
issue-number: 1
body: "✅ Build successful"
edit-mode: append
append-marker: "workflow-build-summary"
append-mode: replace # or "add-after"
Comment result:
Some previous comment content...
<!-- peter-evans/create-or-update-comment:append-marker-start:workflow-build-summary -->
✅ Build successful
<!-- peter-evans/create-or-update-comment:append-marker-end:workflow-build-summary -->
Second Run with replace Mode:
Some previous comment content...
<!-- peter-evans/create-or-update-comment:append-marker-start:workflow-build-summary -->
✅ Build successful
<!-- peter-evans/create-or-update-comment:append-marker-end:workflow-build-summary -->
(Replaces previous content instead of duplicating it.)
Second Run with add-after Mode:
Some previous comment content...
<!-- peter-evans/create-or-update-comment:append-marker-start:workflow-build-summary -->
✅ Build successful
✅ Build successful
<!-- peter-evans/create-or-update-comment:append-marker-end:workflow-build-summary -->
(Adds new content after the last appended block and enlarge markers scope.)
Multiple Actions Using Different Markers:
Some previous comment content...
<!-- peter-evans/create-or-update-comment:append-marker-start:workflow-build-summary -->
✅ Build successful
<!-- peter-evans/create-or-update-comment:append-marker-end:workflow-build-summary -->
<!-- peter-evans/create-or-update-comment:append-marker-start:lint-results -->
⚠️ 2 lint warnings
<!-- peter-evans/create-or-update-comment:append-marker-end:lint-results -->
(Each action operates within its own designated section.)
Why this approach?
- Prevents duplication: Ensures the same content isn’t appended multiple times.
- Avoids workflow interference: Configurable markers allow multiple actions to edit the same comment ~safely.
Alternative Solutions Considered
- Hash-based deduplication: Complex and unreliable for large, formatted content.
- Manually checking comment content before updating: Cumbersome in workflow logic.