2025-05-03 23:46:28 +07:00

72 lines
3.9 KiB
YAML

# File: .gitea/workflows/network-test.yml
# --- Updated Version ---
name: Network Connectivity Test (Updated)
on:
push: # Chạy khi push code (có thể giới hạn vào một nhánh test nếu muốn)
branches:
- main # Ví dụ: chỉ chạy khi push lên nhánh test-network
jobs:
connectivity_check:
name: Check Runner to Server Connectivity
runs-on: ubuntu-latest # Đảm bảo dùng cùng label với runner của bạn
steps:
- name: Wait a bit (optional)
run: sleep 5 # Đợi 5 giây phòng trường hợp vẫn do timing
- name: Cập nhật và cài curl + dnsutils
run: |
apt update
apt install -y curl dnsutils iputils-ping
- name: Install Network Tools & Debug Info
id: debug_network
run: |
echo "========== Network Debug Info Start =========="
echo "[INFO] Running as user: $(whoami) with ID: $(id)"
echo "[INFO] Runner Environment Variables:"
env
echo "---------------------------------------------"
echo "[INFO] Attempting to install network tools..."
apk update && apk add curl iputils bind-tools
echo "[INFO] Tool installation attempt finished."
echo "---------------------------------------------"
echo "[INFO] /etc/resolv.conf:"
cat /etc/resolv.conf || echo "[WARN] Cannot read resolv.conf"
echo "---------------------------------------------"
echo "[INFO] /etc/hosts:"
cat /etc/hosts || echo "[WARN] Cannot read hosts"
echo "---------------------------------------------"
echo "[INFO] Pinging 'server' (Hostname)..."
ping -c 3 server || echo "[WARN] Ping 'server' failed"
echo "---------------------------------------------"
echo "[INFO] Pinging 'gitea_server' (Container Name)..."
ping -c 3 gitea_server || echo "[WARN] Ping 'gitea_server' failed"
echo "---------------------------------------------"
echo "[INFO] nslookup 'server'..."
nslookup server || echo "[WARN] nslookup 'server' failed"
echo "---------------------------------------------"
echo "[INFO] nslookup 'gitea_server'..."
nslookup gitea_server || echo "[WARN] nslookup 'gitea_server' failed"
echo "---------------------------------------------"
echo "[INFO] dig 'server'..."
dig server || echo "[WARN] dig 'server' failed"
echo "---------------------------------------------"
echo "[INFO] dig 'gitea_server'..."
dig gitea_server || echo "[WARN] dig 'gitea_server' failed"
echo "---------------------------------------------"
echo "[INFO] Checking for proxy env vars..."
env | grep -i proxy || echo "[INFO] No proxy environment variables found."
echo "========== Network Debug Info End =========="
# Không đặt continue-on-error nữa, nếu cài tool lỗi thì nên dừng lại
- name: Test Connection with Curl (server)
run: curl -v -f --connect-timeout 10 http://server:3000 || echo "[ERROR] Curl to http://server:3000 failed"
continue-on-error: true # Cho phép các bước sau vẫn chạy dù bước này lỗi
- name: Test Connection with Curl (gitea_server)
run: curl -v -f --connect-timeout 10 http://gitea_server:3000 || echo "[ERROR] Curl to http://gitea_server:3000 failed"
continue-on-error: true
- name: Test Connection with Git (server)
run: git ls-remote http://server:3000/ulflow_phattt2901/matching_app/ || echo "[ERROR] Git ls-remote to http://server:3000 failed"
continue-on-error: true
- name: Test Connection with Git (gitea_server)
run: git ls-remote http://gitea_server:3000/ulflow_phattt2901/matching_app/ || echo "[ERROR] Git ls-remote to http://gitea_server:3000 failed"
continue-on-error: true