diff --git a/.github/workflows/RebasePRByComments.yml b/.github/workflows/RebasePRByComments.yml index db4554b..a875454 100644 --- a/.github/workflows/RebasePRByComments.yml +++ b/.github/workflows/RebasePRByComments.yml @@ -26,20 +26,9 @@ 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: 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,52 @@ 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 runId = '${{ github.run_id }}'; + + const body = MARKER + '\n' + + '## Rebase Workflow - Run #' + runId + '\n' + + '\n' + + '**Status:** ' + message + '\n' + + '\n' + + '**Details:**\n' + + '- Branch: `' + branch + '` → `' + baseBranch + '`\n' + + '- Run: [View logs](' + runUrl + ')\n' + + '- Triggered by: @${{ github.event.comment.user.login }}\n' + + '\n' + + '---\n' + + '*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, + }); + } diff --git a/LemonTree.DevOps.Demo.qeax b/LemonTree.DevOps.Demo.qeax index 132c4f6..1168674 100644 --- a/LemonTree.DevOps.Demo.qeax +++ b/LemonTree.DevOps.Demo.qeax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e24828b6a0b1ec60ad75ed20f62caa4eb74e445bde76087cb7dc87366d8f0a17 -size 2412544 +oid sha256:a8d62aaa5fe15ca724028f95d751d045cad88f6d697a6403f1debad29e8a3484 +size 2396160 diff --git a/README.md b/README.md index 986ec8a..a811e70 100644 --- a/README.md +++ b/README.md @@ -48,3 +48,5 @@ On run the version from the "main" branch is executed and never the version from ## Repo Notes There is an [orphan branch "svg"](https://github.com/LieberLieber/LemonTree.DevOps.Demo/tree/svg) that is used to store SVG files created by GitHub Actions. + +Custom Actions Cache the large executables needed! \ No newline at end of file