ci(upstream-merge): fix unbound DEFAULT_BRANCH in cleanup step; make artifacts upload tolerant; remove duplicate PR JS

This commit is contained in:
James Peter
2025-09-07 20:13:38 +10:00
parent 3507c43e9b
commit b6f6d81208
+2 -18
View File
@@ -312,6 +312,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.CODE_GH_PAT || github.token }}
REPO: ${{ github.repository }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch || 'main' }}
run: |
set -euo pipefail
OWNER=${REPO%%/*}
@@ -443,6 +444,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: upstream-merge-artifacts
if-no-files-found: warn
path: |
.github/auto/COMMITS.json
.github/auto/DELETED_ON_DEFAULT.txt
@@ -491,21 +493,3 @@ jobs:
const pr = await github.rest.pulls.create({ owner, repo, title, head: headRef, base, body });
core.notice(`Created PR #${pr.data.number}`);
}
// Ensure the branch exists on origin before creating/updating a PR.
const ref = `heads/${head}`;
try {
await github.rest.git.getRef({ owner, repo, ref });
} catch (e) {
core.notice(`Branch '${head}' not found on origin; skipping PR creation.`);
return;
}
const headRef = `${owner}:${head}`;
const prs = await github.rest.pulls.list({ owner, repo, state: 'open', head: headRef });
if (prs.data.length) {
const pr = prs.data[0];
await github.rest.pulls.update({ owner, repo, pull_number: pr.number, title, body });
core.notice(`Updated PR #${pr.number}`);
} else {
const pr = await github.rest.pulls.create({ owner, repo, title, head: headRef, base, body });
core.notice(`Created PR #${pr.data.number}`);
}