From f89387ac397e104c1096c24074da36d27a3177f7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 24 Jun 2025 15:58:28 +0100 Subject: [PATCH] workflows/sync-default-branches: force push instead of force-with-lease. Force-with-lease doesn't work as expected with a shallow clone. --- .github/workflows/sync-default-branches.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sync-default-branches.yml b/.github/workflows/sync-default-branches.yml index 1635b6bc49..b171b3c992 100644 --- a/.github/workflows/sync-default-branches.yml +++ b/.github/workflows/sync-default-branches.yml @@ -45,19 +45,20 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: - fetch-depth: 0 + fetch-depth: 1 persist-credentials: true - - name: Setup target branch + - name: Get target SHA + id: sha run: | - git checkout "${TARGET_BRANCH}" || git checkout -b "${TARGET_BRANCH}" - git reset --hard "origin/${SOURCE_BRANCH}" + TARGET_SHA=$(git ls-remote origin "refs/heads/${SOURCE_BRANCH}" | cut -f1) + echo "target=${TARGET_SHA}" >> "$GITHUB_OUTPUT" env: SOURCE_BRANCH: ${{ steps.branches.outputs.source }} - TARGET_BRANCH: ${{ steps.branches.outputs.target }} - name: Push target branch if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' - run: git push origin "${TARGET_BRANCH}" --force-with-lease + run: git push origin "${TARGET_SHA}:refs/heads/${TARGET_BRANCH}" --force env: + TARGET_SHA: ${{ steps.sha.outputs.target }} TARGET_BRANCH: ${{ steps.branches.outputs.target }}