Skip to content
Merged
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
26 changes: 18 additions & 8 deletions .github/workflows/check-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ jobs:
if [ "$EXISTING" = "$GENERATED" ]; then
echo "Fix branch already contains identical changes — skipping push to preserve PR approvals."
echo "pushed=false" >> "$GITHUB_OUTPUT"
echo "branch_ready=true" >> "$GITHUB_OUTPUT"
echo "fix_branch=$FIX_BRANCH" >> "$GITHUB_OUTPUT"
echo "base_branch=$BASE_BRANCH" >> "$GITHUB_OUTPUT"
exit 0
fi
fi
Expand All @@ -424,18 +427,20 @@ jobs:
echo "base_branch=$BASE_BRANCH" >> "$GITHUB_OUTPUT"

- name: Create or update fix PR
if: steps.push.outputs.pushed == 'true'
if: steps.push.outputs.pushed == 'true' || steps.push.outputs.branch_ready == 'true'
uses: actions/github-script@v7
env:
FIX_BRANCH: ${{ steps.push.outputs.fix_branch }}
BASE_BRANCH: ${{ steps.push.outputs.base_branch }}
PUSHED: ${{ steps.push.outputs.pushed }}
with:
github-token: ${{ secrets.PGEDGE_BUILDER_TOKEN }}
script: |
const fs = require('fs');
const body = fs.readFileSync('/tmp/drift-report.md', 'utf8');
const fixBranch = process.env.FIX_BRANCH;
const baseBranch = process.env.BASE_BRANCH;
const pushed = process.env.PUSHED === 'true';
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');

const { data: prs } = await github.rest.pulls.list({
Expand All @@ -445,13 +450,18 @@ jobs:
});

if (prs.length > 0) {
const prNumber = prs[0].number;
console.log(`Updating existing PR #${prNumber}`);
await github.rest.issues.createComment({
owner, repo,
issue_number: prNumber,
body,
});
if (pushed) {
// New content was pushed — update the PR body to reflect latest drift
const prNumber = prs[0].number;
console.log(`Updating PR #${prNumber} body`);
await github.rest.pulls.update({
owner, repo,
pull_number: prNumber,
body,
});
} else {
console.log(`PR already open and branch unchanged — no update needed`);
}
} else {
console.log('Creating new fix PR');
await github.rest.pulls.create({
Expand Down
Loading