diff --git a/.gitea/workflows/backport-commoncore.yml b/.gitea/workflows/backport-commoncore.yml index 89970fe6..88f2a54f 100644 --- a/.gitea/workflows/backport-commoncore.yml +++ b/.gitea/workflows/backport-commoncore.yml @@ -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</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 diff --git a/.gitea/workflows/pull-request-build.yml b/.gitea/workflows/pull-request-build.yml index 7aa8d812..5c05c37f 100644 --- a/.gitea/workflows/pull-request-build.yml +++ b/.gitea/workflows/pull-request-build.yml @@ -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" \