Skip to content

Commit d6d2755

Browse files
Post in-progress comment in the workflow
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com> Generated-by: Cursor AI
1 parent 384803d commit d6d2755

1 file changed

Lines changed: 22 additions & 17 deletions

File tree

.github/workflows/trigger-rebase.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ jobs:
4949
gh api "repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" \
5050
-f content='rocket' --silent
5151
52+
- name: Post in-progress comment
53+
id: progress-comment
54+
env:
55+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: |
57+
COMMENT_URL=$(gh issue comment "${{ github.event.issue.number }}" \
58+
--repo "${{ github.repository }}" \
59+
--body "Rebase workflow **in progress**... [View run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})")
60+
COMMENT_ID=$(echo "$COMMENT_URL" | grep -oE '[0-9]+$')
61+
echo "comment_id=${COMMENT_ID}" >> "$GITHUB_OUTPUT"
62+
5263
- name: Checkout dw-claude-runner
5364
uses: actions/checkout@v4
5465
with:
@@ -91,26 +102,20 @@ jobs:
91102
fi
92103
echo "pr_url=${PR_URL}" >> "$GITHUB_OUTPUT"
93104
94-
- name: Comment success on issue
95-
if: success()
105+
- name: Update comment with result
106+
if: always() && steps.progress-comment.outputs.comment_id
96107
env:
97108
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98109
PR_URL: ${{ steps.extract-pr.outputs.pr_url }}
110+
COMMENT_ID: ${{ steps.progress-comment.outputs.comment_id }}
111+
RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
99112
run: |
100-
if [ -n "$PR_URL" ]; then
101-
BODY="Rebase workflow **succeeded**. [View run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n\nCreated PR: ${PR_URL}"
113+
if [ "${{ job.status }}" = "success" ] && [ -n "$PR_URL" ]; then
114+
BODY="Rebase workflow **succeeded**. [View run](${RUN_URL})\n\nCreated PR: ${PR_URL}"
115+
elif [ "${{ job.status }}" = "success" ]; then
116+
BODY="**Warning**: Workflow completed but no PR was created. Something may have gone wrong. [View logs](${RUN_URL})"
102117
else
103-
BODY="**Warning**: Workflow completed but no PR was created. Something may have gone wrong. [View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
118+
BODY="Rebase workflow **failed**. [View run](${RUN_URL})"
104119
fi
105-
gh issue comment "${{ github.event.issue.number }}" \
106-
--repo "${{ github.repository }}" \
107-
--body "$(echo -e "$BODY")"
108-
109-
- name: Comment failure on issue
110-
if: failure()
111-
env:
112-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113-
run: |
114-
gh issue comment "${{ github.event.issue.number }}" \
115-
--repo "${{ github.repository }}" \
116-
--body "Rebase workflow **failed**. [View run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
120+
gh api "repos/${{ github.repository }}/issues/comments/${COMMENT_ID}" \
121+
-X PATCH -f body="$(echo -e "$BODY")"

0 commit comments

Comments
 (0)