-
Notifications
You must be signed in to change notification settings - Fork 0
fix(scheduler): preserve default-branch gate for targeted stack PRs #1197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,6 +244,7 @@ jobs: | |
| { | ||
| printf 'repository=%s\n' "$GITHUB_REPOSITORY" | ||
| printf 'base_branch=%s\n' "$DEFAULT_BRANCH" | ||
| printf 'repository_default_branch=%s\n' "$DEFAULT_BRANCH" | ||
| } >>"$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
@@ -281,13 +282,15 @@ jobs: | |
| live_head_repository="$(jq -r '.head.repo.full_name // empty' <<<"$pull_json")" | ||
| live_base_branch="$(jq -r '.base.ref // empty' <<<"$pull_json")" | ||
| live_head_sha="$(jq -r '.head.sha // empty' <<<"$pull_json")" | ||
| repository_default_branch="$(gh api "repos/${TARGET_REPOSITORY_INPUT}" --jq '.default_branch // empty')" | ||
| if [ "$live_number" != "$TARGET_PR_NUMBER" ] || | ||
| [ "$live_state" != "open" ] || | ||
| [ "$live_base_repository" != "$TARGET_REPOSITORY_INPUT" ] || | ||
| [ "$live_head_repository" != "$TARGET_REPOSITORY_INPUT" ] || | ||
| [ -z "$live_base_branch" ] || | ||
| [ -z "$repository_default_branch" ] || | ||
| ! [[ "$live_head_sha" =~ ^[0-9a-fA-F]{40}$ ]]; then | ||
| printf '::error::Targeted scheduler dispatch rejected closed, cross-repository, or malformed live PR metadata. target=%s pr=%s state=%s base_repository=%s head_repository=%s base_branch=%s head_sha=%s\n' "$TARGET_REPOSITORY_INPUT" "$TARGET_PR_NUMBER" "${live_state:-<missing>}" "${live_base_repository:-<missing>}" "${live_head_repository:-<missing>}" "${live_base_branch:-<missing>}" "${live_head_sha:-<missing>}" | ||
| printf '::error::Targeted scheduler dispatch rejected closed, cross-repository, or malformed live PR metadata. target=%s pr=%s state=%s base_repository=%s head_repository=%s base_branch=%s repository_default_branch=%s head_sha=%s\n' "$TARGET_REPOSITORY_INPUT" "$TARGET_PR_NUMBER" "${live_state:-<missing>}" "${live_base_repository:-<missing>}" "${live_head_repository:-<missing>}" "${live_base_branch:-<missing>}" "${repository_default_branch:-<missing>}" "${live_head_sha:-<missing>}" | ||
| exit 1 | ||
| fi | ||
| if [ -n "$TARGET_BASE_BRANCH_INPUT" ] && | ||
|
|
@@ -299,9 +302,10 @@ jobs: | |
| { | ||
| printf 'repository=%s\n' "$TARGET_REPOSITORY_INPUT" | ||
| printf 'base_branch=%s\n' "$live_base_branch" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| printf 'repository_default_branch=%s\n' "$repository_default_branch" | ||
| printf 'head_sha=%s\n' "$live_head_sha" | ||
| } >>"$GITHUB_OUTPUT" | ||
| printf 'Validated exact targeted scheduler dispatch for %s#%s at %s on base %s.\n' "$TARGET_REPOSITORY_INPUT" "$TARGET_PR_NUMBER" "$live_head_sha" "$live_base_branch" | ||
| printf 'Validated exact targeted scheduler dispatch for %s#%s at %s on base %s; repository default branch is %s.\n' "$TARGET_REPOSITORY_INPUT" "$TARGET_PR_NUMBER" "$live_head_sha" "$live_base_branch" "$repository_default_branch" | ||
|
|
||
| - name: Resolve trusted scheduler source ref | ||
| id: trusted_source | ||
|
|
@@ -482,7 +486,7 @@ jobs: | |
| env: | ||
| GH_TOKEN: ${{ secrets.PR_REVIEW_MERGE_TOKEN || secrets.OPENCODE_APPROVE_TOKEN || steps.scheduler_app_token.outputs.token || github.token }} | ||
| TARGET_REPOSITORY: ${{ steps.targeted_dispatch.outputs.repository }} | ||
| TARGET_DEFAULT_BRANCH: ${{ steps.targeted_dispatch.outputs.base_branch }} | ||
| TARGET_DEFAULT_BRANCH: ${{ steps.targeted_dispatch.outputs.repository_default_branch }} | ||
| SCHEDULER_ACTIONS_TOKEN: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.target_repository != '' && (secrets.PR_REVIEW_MERGE_TOKEN || secrets.OPENCODE_APPROVE_TOKEN || steps.scheduler_app_token.outputs.token) || github.token }} | ||
| # Same-repository dispatch credential: when this scheduler runs inside | ||
| # ContextualWisdomLab/.github (the repository the required workflows are | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: project_flow now derived from repository default branch
The Inspect step's
project_flowselection (pr-review-merge-scheduler.yml) now switches on the repository default branch rather than the live PR base ref. For a stack PR onto a feature branch, this changes the resolved flow (e.g. adevelopdefault now yieldsgit-flowinstead of the formergithub-flowfallthrough).(Refers to this code)
Was this helpful? React with 👍 or 👎 to provide feedback.