From e448d5ebaf151d99c2fb4f7a9d0850c8e444d318 Mon Sep 17 00:00:00 2001 From: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Date: Fri, 27 Mar 2026 06:37:24 +0000 Subject: [PATCH 1/6] ci: better ci --- .gitea/workflows/release.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index ecd03bd..9615c4d 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -17,6 +17,15 @@ jobs: outputs: new_version: ${{ steps.set_output.outputs.version }} steps: + - name: Setup SSH Key + run: | + mkdir -p ~/.ssh + chmod 700 ~/.ssh + echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + + ssh-keyscan -p 222 -t ed25519 172.22.0.1 >> ~/.ssh/known_hosts + - uses: actions/checkout@v6 with: fetch-depth: 0 @@ -69,9 +78,12 @@ jobs: git config --global user.name "gitea-actions" git config --global user.email "actions-user@noreply.git.demonkernel.io.vn" + git remote set-url origin ssh://git@172.22.0.1:222/FoodSurf/backend.git + git rm -r --cached . git add . git commit -m "chore: release [ci skip]" + git push fi From 2873952f101194642b1d20e452921ca5c121294b Mon Sep 17 00:00:00 2001 From: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Date: Sun, 29 Mar 2026 13:52:32 +0000 Subject: [PATCH 2/6] fix: ci script --- .gitea/workflows/release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 9615c4d..7b82fff 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -19,6 +19,7 @@ jobs: steps: - name: Setup SSH Key run: | + set -x mkdir -p ~/.ssh chmod 700 ~/.ssh echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519 From 7534f41c6edbc462d2e3fcb6cabff51fd0795ffe Mon Sep 17 00:00:00 2001 From: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Date: Sun, 29 Mar 2026 13:54:37 +0000 Subject: [PATCH 3/6] fix: ci script --- .gitea/workflows/release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 7b82fff..0191ca5 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -20,6 +20,7 @@ jobs: - name: Setup SSH Key run: | set -x + ip add mkdir -p ~/.ssh chmod 700 ~/.ssh echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519 From 801b804d2d380422fee5b50e22882e51fc572eda Mon Sep 17 00:00:00 2001 From: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Date: Sun, 29 Mar 2026 13:56:08 +0000 Subject: [PATCH 4/6] fix: ci script --- .gitea/workflows/release.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 0191ca5..3eff75a 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -20,7 +20,13 @@ jobs: - name: Setup SSH Key run: | set -x - ip add + + if command -v apk >/dev/null; then apk add --no-network iproute2 netcat-openbsd || apk add iproute2 netcat-openbsd; + elif command -v apt-get >/dev/null; then apt-get update && apt-get install -y iproute2 netcat-openbsd; fi + + # Kiểm tra IP của Runner + ip addr show || ifconfig + mkdir -p ~/.ssh chmod 700 ~/.ssh echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519 From 5593c4fcccbd8cc87d34f421bf16e4781b73865b Mon Sep 17 00:00:00 2001 From: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Date: Sun, 29 Mar 2026 14:06:39 +0000 Subject: [PATCH 5/6] fix: ci script --- .gitea/workflows/release.yaml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 3eff75a..79a0c3f 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -17,22 +17,23 @@ jobs: outputs: new_version: ${{ steps.set_output.outputs.version }} steps: + - name: Calculate and Export Target IP + run: | + # 1. Lấy IP hiện tại và tính toán IP đích (đổi octet cuối thành .1) + RUNNER_IP=$(hostname -I | awk '{print $1}') + CALCULATED_IP=$(echo $RUNNER_IP | cut -d'.' -f1-3).1 + + # 2. Đưa vào biến môi trường toàn cục của Job + echo "TARGET_IP=${CALCULATED_IP}" >> $GITHUB_ENV + - name: Setup SSH Key run: | - set -x - - if command -v apk >/dev/null; then apk add --no-network iproute2 netcat-openbsd || apk add iproute2 netcat-openbsd; - elif command -v apt-get >/dev/null; then apt-get update && apt-get install -y iproute2 netcat-openbsd; fi - - # Kiểm tra IP của Runner - ip addr show || ifconfig - mkdir -p ~/.ssh chmod 700 ~/.ssh echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 - ssh-keyscan -p 222 -t ed25519 172.22.0.1 >> ~/.ssh/known_hosts + ssh-keyscan -p 222 -t ed25519 $TARGET_IP >> ~/.ssh/known_hosts - uses: actions/checkout@v6 with: @@ -86,7 +87,7 @@ jobs: git config --global user.name "gitea-actions" git config --global user.email "actions-user@noreply.git.demonkernel.io.vn" - git remote set-url origin ssh://git@172.22.0.1:222/FoodSurf/backend.git + git remote set-url origin ssh://git@$TARGET_IP:222/FoodSurf/backend.git git rm -r --cached . git add . From 9ad66301dea89ac5b48339e5806f08655ad1a95e Mon Sep 17 00:00:00 2001 From: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Date: Sun, 29 Mar 2026 14:12:07 +0000 Subject: [PATCH 6/6] ci: better ci --- scripts/release.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.ts b/scripts/release.ts index 73e908c..3aecb0b 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -10,7 +10,7 @@ const zipPath = "release.zip"; console.log(`📦 Đang nén file cho version: ${version}...`); -execSync(`zip -r ${zipPath} out`, { +execSync(`cd out && zip -r ../${zipPath} .`, { stdio: "inherit", });