fix(ci): use SSH fallback when HTTPS checkout times out
- Replace actions/checkout with manual git clone - Try HTTPS with 30s timeout, fallback to SSH port 2222 - Uses DEPLOY_KEY secret for SSH authentication
This commit is contained in:
@@ -2,7 +2,7 @@ name: CI / CD Pipeline
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, develop]
|
branches: [ main, develop ]
|
||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
@@ -14,18 +14,19 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- name: 📥 Checkout (HTTPS)
|
- name: Checkout (SSH fallback for HTTPS timeout)
|
||||||
uses: actions/checkout@v4
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: 📥 Checkout (SSH fallback)
|
|
||||||
if: failure()
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
# Try HTTPS first with timeout
|
||||||
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_rsa
|
if timeout 30 git clone --depth 1 https://git.np-dms.work/np-dms/lcbp3.git . 2>/dev/null; then
|
||||||
chmod 600 ~/.ssh/id_rsa
|
echo "HTTPS checkout successful"
|
||||||
ssh-keyscan -p 2222 git.np-dms.work >> ~/.ssh/known_hosts
|
else
|
||||||
git clone ssh://git@git.np-dms.work:2222/np-dms/lcbp3.git .
|
echo "HTTPS failed, using SSH fallback"
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan -p 2222 git.np-dms.work >> ~/.ssh/known_hosts
|
||||||
|
git clone --depth 1 ssh://git@git.np-dms.work:2222/np-dms/lcbp3.git .
|
||||||
|
fi
|
||||||
git fetch origin main
|
git fetch origin main
|
||||||
git reset --hard origin/main
|
git reset --hard origin/main
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ jobs:
|
|||||||
node-version: 20
|
node-version: 20
|
||||||
# ลบ cache: "pnpm" ออก — ใช้ volume mount บน runner แทน
|
# ลบ cache: "pnpm" ออก — ใช้ volume mount บน runner แทน
|
||||||
|
|
||||||
# ── [2] ชี้ store ไปที่ volume ที่ mount ไว้ ─────────────
|
# ── [2] ชี้ store ไปที่ volume ที่ mount ไว้ ─────────────
|
||||||
- name: 🔧 Set pnpm store path
|
- name: 🔧 Set pnpm store path
|
||||||
run: pnpm config set store-dir /root/.local/share/pnpm
|
run: pnpm config set store-dir /root/.local/share/pnpm
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user