Skip to content

Commit 49f82a1

Browse files
committed
Fix problem with fetch depth of 0
1 parent 544753b commit 49f82a1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

.github/workflows/update-from-template.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ jobs:
183183
steps:
184184
- uses: actions/checkout@v4
185185
with:
186+
# Required because otherwise there are always changes detected when executing diff/rev-list
187+
fetch-depth: 0
186188
# If no PAT is used the following error occurs on a push:
187189
# refusing to allow a GitHub App to create or update workflow `.github/workflows/xxx.yml` without `workflows` permission
188190
token: ${{ secrets.UPDATE_FROM_TEMPLATE_PAT }}
@@ -208,7 +210,7 @@ jobs:
208210
209211
echo "Checking if update-branch-merged exists"
210212
git fetch
211-
if [[ $(git rev-parse origin/${{ env.UPDATE_BRANCH_MERGED }}) ]]; then
213+
if [[ $(git ls-remote --exit-code --heads origin ${{ env.UPDATE_BRANCH_MERGED }}) ]]; then
212214
echo "Branch origin/${{ env.UPDATE_BRANCH_MERGED }} is missing"
213215
exit 0
214216
fi
@@ -269,8 +271,11 @@ jobs:
269271
base_branch=$(git branch --show-current)
270272
echo "Base branch is $base_branch"
271273
272-
echo "Fetching..."
273-
git fetch
274+
echo "Fully fetching..."
275+
git fetch --unshallow || true
276+
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
277+
git fetch origin
278+
274279
if [[ $(git rev-parse origin/${{ env.UPDATE_BRANCH_MERGED }}) ]]; then
275280
echo "Branch origin/${{ env.UPDATE_BRANCH_MERGED }} is missing"
276281
exit 0

0 commit comments

Comments
 (0)