Test Backporting

Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
2026-05-15 14:47:37 +02:00
parent b923b98b2c
commit 39898825ef
2 changed files with 8 additions and 23 deletions
+7 -22
View File
@@ -43,8 +43,6 @@ jobs:
{
echo "should_backport=$([[ "$merged" == "true" && "$base_branch" == "main" && "$has_disable_label" != "true" ]] && echo true || echo false)"
echo "pr_number=$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")"
echo "base_sha=$(jq -r '.pull_request.base.sha' "$GITHUB_EVENT_PATH")"
echo "head_sha=$(jq -r '.pull_request.head.sha' "$GITHUB_EVENT_PATH")"
echo "pr_title<<EOF"
jq -r '.pull_request.title' "$GITHUB_EVENT_PATH"
echo "EOF"
@@ -71,8 +69,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.eligibility.outputs.pr_number }}
PR_TITLE: ${{ steps.eligibility.outputs.pr_title }}
BASE_SHA: ${{ steps.eligibility.outputs.base_sha }}
HEAD_SHA: ${{ steps.eligibility.outputs.head_sha }}
run: |
set -euo pipefail
@@ -87,29 +83,18 @@ jobs:
fi
git fetch --prune origin '+refs/heads/version/*:refs/remotes/origin/version/*'
git fetch origin "refs/pull/${PR_NUMBER}/head:refs/remotes/origin/pr/${PR_NUMBER}/head" || true
diff_head="${HEAD_SHA}"
if ! git cat-file -e "${diff_head}^{commit}" 2>/dev/null; then
diff_head="refs/remotes/origin/pr/${PR_NUMBER}/head"
fi
curl -fsSL \
-H "Accept: text/plain" \
-H "Authorization: token ${GITHUB_TOKEN}" \
"${api_url}/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}.diff" \
-o pull-request.diff
if ! git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null; then
echo "Base commit ${BASE_SHA} is not available."
exit 1
fi
if ! git cat-file -e "${diff_head}^{commit}" 2>/dev/null; then
echo "Head commit ${HEAD_SHA} is not available."
exit 1
fi
if git diff --quiet "${BASE_SHA}...${diff_head}" -- "${BACKPORT_PATH}"; then
if ! grep -Eq "^diff --git a/${BACKPORT_PATH}/" pull-request.diff; then
echo "Pull request #${PR_NUMBER} has no ${BACKPORT_PATH} changes to backport."
exit 0
fi
git diff --binary "${BASE_SHA}...${diff_head}" -- "${BACKPORT_PATH}" > commoncore-backport.patch
mapfile -t target_branches < <(git for-each-ref --format='%(refname:strip=3)' refs/remotes/origin/version)
if [[ "${#target_branches[@]}" -eq 0 ]]; then
echo "No version/* branches found."
@@ -123,7 +108,7 @@ jobs:
git checkout -B "${backport_branch}" "origin/${target_branch}"
git reset --hard "origin/${target_branch}"
if ! git apply --3way --index commoncore-backport.patch; then
if ! git apply --3way --index --include="${BACKPORT_PATH}/**" pull-request.diff; then
echo "Failed to apply CommonCore backport for ${target_branch}."
exit 1
fi
+1 -1
View File
@@ -68,7 +68,7 @@ jobs:
api_url="${GITHUB_API_URL:-${GITHUB_SERVER_URL}/api/v1}"
curl -fsS -X PUT \
curl -fsS -X POST \
-H "Accept: application/json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \