Repository navigation
fix(ci): inbox-steward-intake publishes through PRs and fails loudly #943
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| # open-data-pr.sh — land machine-written data files on main through a PR | ||
| # | ||
| # Usage: open-data-pr.sh <branch-suffix> <title> <path>... | ||
| # | ||
| # Commits <path>... on a new branch `inbox-steward/<run_id>-<suffix>`, pushes | ||
| # it, opens a PR against main and queues a squash auto-merge. Used by | ||
| # inbox-steward-intake.yml instead of `git push origin HEAD` to main, which | ||
| # bypassed review and signing and was masked so a refusal stayed green. | ||
| # | ||
| # Needs: GH_TOKEN (a credential with Contents and Pull requests write on this | ||
| # repository), GITHUB_RUN_ID, GITHUB_REPOSITORY, and a checkout whose `origin` | ||
| # authenticates with the same credential. Every failure exits non-zero. | ||
| set -euo pipefail | ||
|
|
||
| if [ "$#" -lt 3 ]; then | ||
| echo "usage: $0 <branch-suffix> <title> <path>..." >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| suffix="$1" | ||
| title="$2" | ||
| shift 2 | ||
|
|
||
| git add -- "$@" | ||
| if git diff --cached --quiet; then | ||
| echo "No changes under $* — nothing to publish." | ||
| exit 0 | ||
| fi | ||
|
|
||
| branch="inbox-steward/${GITHUB_RUN_ID}-${suffix}" | ||
| git switch -c "$branch" | ||
|
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.
When a maintainer starts the Useful? React with 👍 / 👎. |
||
| git commit -m "$title" | ||
| git push origin "HEAD:refs/heads/${branch}" | ||
|
|
||
| pr_url="$(gh pr create --repo "$GITHUB_REPOSITORY" --base main --head "$branch" \ | ||
| --title "$title" \ | ||
| --body "Machine-written by inbox-steward-intake.yml, run ${GITHUB_RUN_ID}. Data files only.")" | ||
| echo "opened ${pr_url}" | ||
|
|
||
| # --auto queues the merge until the base-branch policy allows it; a bare | ||
| # merge right after creation is refused before the policy settles. | ||
| gh pr merge "${pr_url##*/}" --repo "$GITHUB_REPOSITORY" --squash --auto --delete-branch | ||
|
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.
When required checks are pending, Useful? React with 👍 / 👎. |
||
| echo "auto-merge queued for ${pr_url}" | ||
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.
If an attempt fails after pushing this branch but before completing the PR/merge operation, rerunning the same workflow uses the unchanged
GITHUB_RUN_IDand reconstructs the same branch name. The new commit is created independently frommain, so the push is normally rejected as non-fast-forward (or PR creation collides with the existing PR), preventing the rerun from recovering from the original transient failure. IncludeGITHUB_RUN_ATTEMPTor explicitly resume/clean up the existing branch.Useful? React with 👍 / 👎.