@@ -610,9 +610,16 @@ jobs:
610610 git config --local user.email "github-actions[bot]@users.noreply.github.com"
611611 git config --local user.name "github-actions[bot]"
612612
613- # Check for changes in remote and pull if needed
613+ # Set merge strategy to avoid conflicts prompt
614+ git config pull.rebase false
615+
616+ # Fetch latest changes from remote
617+ echo "Fetching latest changes from remote..."
618+ git fetch origin ${GITHUB_REF_NAME}
619+
620+ # Check for changes in remote and merge if needed
614621 echo "Checking for updates from remote..."
615- git pull origin ${GITHUB_REF_NAME} --no-rebase || echo "Failed to pull, proceeding anyway"
622+ git pull origin ${GITHUB_REF_NAME} --strategy-option theirs || echo "Failed to pull, proceeding anyway"
616623
617624 # Ensure docs/reports directory exists
618625 mkdir -p ./docs/reports/
@@ -632,9 +639,15 @@ jobs:
632639 echo "Committing report files..."
633640 git commit -m "Add security scan reports [skip ci]"
634641
635- # Push to the repository
642+ # Handle potential conflicts during push
636643 echo "Pushing changes to the repository..."
637- git push origin ${GITHUB_REF_NAME}
644+ git push origin ${GITHUB_REF_NAME} || {
645+ # If push failed, try pull and merge again
646+ echo "Push failed, attempting to merge remote changes and retry..."
647+ git pull origin ${GITHUB_REF_NAME} --strategy-option theirs
648+ # Try push again
649+ git push origin ${GITHUB_REF_NAME} || echo "Failed to push after merge attempt"
650+ }
638651
639652 echo "Reports have been committed and pushed to the repository."
640653 echo "View them at: https://github.com/${GITHUB_REPOSITORY}/tree/${GITHUB_REF_NAME}/docs/reports"
0 commit comments