Skip to content

Commit 24c7071

Browse files
yeelali14Linearb CI
andauthored
Improve error handling in git commands within action.yml (#479)
- Added warnings for failed fetch of the head branch if it has been deleted and ensure the action continues even if a checkout fails. Co-authored-by: Linearb CI <linearb-ci@gmail.com>
1 parent 9df1bd8 commit 24c7071

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ runs:
8686
git config checkout.defaultRemote origin
8787
git fetch --shallow-since="6 months ago" origin $'${{ steps.safe-strings.outputs.base_ref }}'
8888
git remote add upstream $'${{ steps.safe-strings.outputs.url }}'
89-
git fetch --shallow-since="6 months ago" upstream $'${{ steps.safe-strings.outputs.head_ref }}'
90-
git checkout -b $'upstream/${{ steps.safe-strings.outputs.head_ref}}' $'upstream/${{ steps.safe-strings.outputs.head_ref}}'
91-
git checkout $'${{ steps.safe-strings.outputs.base_ref }}'
92-
git checkout $'${{ steps.safe-strings.outputs.head_ref }}'
89+
git fetch --shallow-since="6 months ago" upstream $'${{ steps.safe-strings.outputs.head_ref }}' || echo "::warning::Failed to fetch head branch. The branch may have been deleted."
90+
git checkout -b $'upstream/${{ steps.safe-strings.outputs.head_ref}}' $'upstream/${{ steps.safe-strings.outputs.head_ref}}' || true
91+
git checkout $'${{ steps.safe-strings.outputs.base_ref }}' || true
92+
git checkout $'${{ steps.safe-strings.outputs.head_ref }}' || true
9393
9494
- name: Create cm folder
9595
shell: bash

0 commit comments

Comments
 (0)