From 94d17d20b542029151dd0c7f92af72ba4bb31ee4 Mon Sep 17 00:00:00 2001 From: Daniel Siegl Date: Thu, 2 Apr 2026 18:10:10 +0200 Subject: [PATCH 1/2] First try --- .github/workflows/RebasePRByComments.yml | 60 ++++++++++++++++++------ 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/.github/workflows/RebasePRByComments.yml b/.github/workflows/RebasePRByComments.yml index db4554b..e92b6fd 100644 --- a/.github/workflows/RebasePRByComments.yml +++ b/.github/workflows/RebasePRByComments.yml @@ -29,17 +29,6 @@ jobs: if: ${{ github.event.issue.pull_request && github.event.comment.body == '/rebase/'}} steps: - - name: Post start message in PR - uses: actions/github-script@v8 - with: - script: | - await github.rest.issues.createComment({ - issue_number: ${{github.event.issue.number}}, - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Starting auto-rebase' - }) - - name: Retrieve Rull Request details id: pr_details uses: actions/github-script@v8 @@ -178,10 +167,51 @@ jobs: uses: actions/github-script@v8 with: script: | - await github.rest.issues.createComment({ - issue_number: ${{steps.pr_details.outputs.number}}, + const MARKER = ''; + const branch = '${{ steps.pr_details.outputs.head }}'; + const baseBranch = '${{ steps.pr_details.outputs.base }}'; + const message = '${{ steps.Rebase.outputs.message }}'; + const runUrl = `${{ env.GitHubProjectRoot }}/actions/runs/${{ github.run_id }}`; + + const body = `${MARKER} +## Rebase Workflow - Run #${{ github.run_id }} + +**Status:** ${message} + +**Details:** +- Branch: \`${branch}\` → \`${baseBranch}\` +- Run: [View logs](${runUrl}) +- Triggered by: @${{ github.event.comment.user.login }} + +--- +*This comment is automatically updated per workflow run*`; + + // Find existing comment for this run + const comments = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, - body: '${{steps.Rebase.outputs.message}}' - }) + issue_number: ${{ steps.pr_details.outputs.number }}, + }); + + const existing = comments.data.find( + cm => cm.user.login === 'github-actions[bot]' && cm.body.includes(MARKER) + ); + + if (existing) { + console.log(`Updating existing comment ${existing.id}`); + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body: body, + }); + } else { + console.log('Creating new comment'); + await github.rest.issues.createComment({ + issue_number: ${{ steps.pr_details.outputs.number }}, + owner: context.repo.owner, + repo: context.repo.repo, + body: body, + }); + } From 10f62df1b5155be5f305afb7a3ecac909e6b299d Mon Sep 17 00:00:00 2001 From: Daniel Siegl Date: Thu, 2 Apr 2026 18:13:37 +0200 Subject: [PATCH 2/2] Updated --- .github/workflows/RebasePRByComments.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/RebasePRByComments.yml b/.github/workflows/RebasePRByComments.yml index e92b6fd..13f74d2 100644 --- a/.github/workflows/RebasePRByComments.yml +++ b/.github/workflows/RebasePRByComments.yml @@ -26,7 +26,7 @@ jobs: shell: pwsh runs-on: windows-latest timeout-minutes: 15 - if: ${{ github.event.issue.pull_request && github.event.comment.body == '/rebase/'}} + if: ${{ github.event.issue.pull_request && (github.event.comment.body == '/rebase/' || github.event.comment.body == '/rb/') }} steps: - name: Retrieve Rull Request details