Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions .github/workflows/RebasePRByComments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = '<!-- rebase-run-${{ github.run_id }} -->';
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,
});
}

4 changes: 2 additions & 2 deletions LemonTree.DevOps.Demo.qeax
Git LFS file not shown
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!