Skip to content
Draft
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
33 changes: 33 additions & 0 deletions .github/shared-actions/check-pr-up-to-date/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Check PR is up to date with base
description: >
Fails when the PR head commit is behind the given base branch.
Callers decide whether to run this before expensive jobs (e.g. full-test-suite).
inputs:
base_ref:
description: Base branch name (e.g. master)
required: true
head_sha:
description: PR head commit SHA to check
required: true

runs:
using: composite
steps:
- name: Checkout PR head
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.head_sha }}

- name: Fail if behind base branch
shell: bash
env:
BASE_REF: ${{ inputs.base_ref }}
run: |
git fetch --no-tags origin "$BASE_REF"
if ! git merge-base --is-ancestor "origin/$BASE_REF" HEAD; then
echo "::error::PR branch is behind '$BASE_REF'. Update the branch, then re-run."
git --no-pager log --oneline "HEAD..origin/$BASE_REF" | head -20
exit 1
fi
echo "PR is up to date with origin/$BASE_REF"