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
19 changes: 16 additions & 3 deletions .github/workflows/on-main-bump-sha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
echo "::notice::Pushed branch ${branch}"

- name: Manage PRs — close old, clean orphans, open new
if: steps.push-branch.outputs.skip != 'true'
if: steps.guard.outputs.skip != 'true' && steps.push-branch.outputs.skip != 'true'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Incomplete guard condition — check skip case still unprotected

The PR fixes the guard skip case, but the condition still doesn't include steps.check.outputs.skip != 'true'. When check determines the SHA is already at HEAD (or the manifest entry is missing), it sets skip=true and exits early, causing push-branch to be skipped entirely. A skipped step outputs an empty string for all its outputs, so steps.push-branch.outputs.skip becomes '' — and '' != 'true' is true — meaning Manage PRs still executes with BRANCH="", NEW_SHA="", and OLD_SHA="". Under set -euo pipefail, the select(.headRefName != "") filter matches every existing bump PR and closes them all, and the orphan-cleanup loop deletes every bump branch — damaging valid open PRs.

Suggested change
if: steps.guard.outputs.skip != 'true' && steps.push-branch.outputs.skip != 'true'
if: steps.guard.outputs.skip != 'true' && steps.check.outputs.skip != 'true' && steps.push-branch.outputs.skip != 'true'

env:
GH_TOKEN: ${{ github.token }}
NEW_SHA: ${{ steps.check.outputs.new_sha }}
Expand Down Expand Up @@ -204,10 +204,23 @@ jobs:
--json number --jq '.[0].number // ""')"
if [ -n "${existing}" ]; then
echo "::notice::PR #${existing} already exists for ${branch}; skipping create"
pr_number="${existing}"
else
gh pr create \
pr_url="$(gh pr create \
--title "chore(manifest): bump YiAgent/OpenCI SHA to ${short_new}" \
--body-file /tmp/pr-body.md \
--base main \
--head "${branch}"
--head "${branch}")"
pr_number="${pr_url##*/}"
echo "::notice::Created PR #${pr_number}"
fi

# 4) Enable auto-merge on the PR so it merges once required checks pass.
# The bump commit only changes manifest.yml and was already tested
# as part of the triggering merge — auto-merging avoids manual
# intervention while still respecting branch protection rules.
if [ -n "${pr_number}" ]; then
gh pr merge "${pr_number}" --auto --squash \
--subject "chore(manifest): bump YiAgent/OpenCI SHA to ${short_new} (#${pr_number})" \
|| echo "::warning::Auto-merge not enabled — repo may lack 'Allow auto-merge' setting."
fi
Loading