Fix push URL construction in workflow
Some checks failed
Auto-Sort Files / auto-sort (push) Has been cancelled

- Correct URL parsing to properly extract domain and repository path
- Fix malformed push URL that was missing proper formatting
- Add debug logging to show URL components for troubleshooting
- Ensure proper HTTPS authentication URL format: https://user:token@domain/repo.git
- Handle both HTTPS and SSH repository URL formats correctly
- Fix issue where push was failing due to incorrect URL construction
This commit is contained in:
2025-08-11 11:21:11 +07:00
parent 004d8c00a6
commit 0e800242d7

View File

@@ -101,9 +101,9 @@ jobs:
# Extract the base URL and repository path
if [[ $REPO_URL == https://* ]]; then
# HTTPS URL format: https://git.b4l.co.th/B4L/repo-name.git
BASE_URL=$(echo $REPO_URL | sed 's|https://\([^/]*\)/.*|https://\1|')
DOMAIN=$(echo $REPO_URL | sed 's|https://\([^/]*\)/.*|\1|')
REPO_PATH=$(echo $REPO_URL | sed 's|https://[^/]*/\(.*\)|\1|')
PUSH_URL="${BASE_URL}/ci-bot:${{ secrets.CI_BOT_TOKEN }}@${REPO_PATH}"
PUSH_URL="https://ci-bot:${{ secrets.CI_BOT_TOKEN }}@${DOMAIN}/${REPO_PATH}"
else
# SSH URL format: git@git.b4l.co.th:B4L/repo-name.git
DOMAIN=$(echo $REPO_URL | sed 's|git@\([^:]*\):.*|\1|')
@@ -111,7 +111,10 @@ jobs:
PUSH_URL="https://ci-bot:${{ secrets.CI_BOT_TOKEN }}@${DOMAIN}/${REPO_PATH}"
fi
echo "Pushing to: $PUSH_URL"
echo "Repository URL: $REPO_URL"
echo "Domain: $DOMAIN"
echo "Repository Path: $REPO_PATH"
echo "Pushing to: https://${DOMAIN}/${REPO_PATH} (with authentication)"
git push $PUSH_URL HEAD:${{ github.ref_name }}
- name: Create summary