Repository navigation
feat(actions): add open-pr-if-needed composite - #50
Merged
Merged
Conversation
Idempotent "create PR if not already open" composite action, extracted from the pattern in nsheaps/.github/.github/workflows/sync-repo-settings.yaml (the "try direct push, fall back to PR" idiom). Inputs: title, body, base, head, repo, token, labels, reviewers. Outputs: pr-number, pr-url, result (existing|opened|nodiff). Body is auto-suffixed with `Workflow run: <server_url>/<repo>/actions/runs/<run_id>` matching the nsheaps self-link convention (see check.yaml). Pre-condition: both head and base branches must already exist on remote. For the "commit local changes + open PR" pattern, peter-evans/create-pull-request is still the right tool — this action is for branches that already exist on the remote (e.g. upstream-sync flows). First consumer: sync-main-to-edge.yaml PR fallback step (PR #48 will be updated in a follow-up commit once this lands). Per Nate review on PR #48: #48 (comment) Co-Authored-By: Agent Alex Picard <alex-nsheaps[bot]@users.noreply.github.com>
3 tasks
Triggered by: 32c4fa0 Workflow run: https://github.com/nsheaps/github-actions/actions/runs/26646093062
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a new reusable composite action
.github/actions/open-pr-if-neededthat idempotently opens a pull request between two branches that already exist on the remote. Extracted from the pattern innsheaps/.github/.github/workflows/sync-repo-settings.yaml(the "try direct push, fall back to PR" idiom) per Nate's review on PR #48.Why
PR #48 inlines a "create PR if not already open" bash block in
sync-main-to-edge.yaml. Nate's review noted this pattern should live in a shared composite action so the idempotency check + workflow-run-link convention are applied consistently across nsheaps workflows.What's in this PR
.github/actions/open-pr-if-needed/action.yml— the compositetitle,body,base,head,repo(defaults togithub.repository),token,labels,reviewerspr-number,pr-url,result(existing|opened|nodiff)head -> basealready exists.Workflow run: <server_url>/<repo>/actions/runs/<run_id>to the body (matches the nsheaps self-link convention used incheck.yaml).result=nodiff) instead of failing the step..github/actions/open-pr-if-needed/README.md— usage docs + example.Scope
Pre-condition: both
headandbasemust already exist on the remote. This action does NOT push commits — for the "commit local changes then open PR" pattern,peter-evans/create-pull-requestremains the right tool (and is still whatsync-repo-settings.yamluses).Follow-up
Once this lands, PR #48 will be updated to call
nsheaps/github-actions/.github/actions/open-pr-if-needed@maininstead of its inline bash block.Test plan
python3 -c 'yaml.safe_load(open(...))')uses: ./.github/actions/open-pr-if-needed, then exercises the path by re-running the sync workflow against a diverged edge branch.