Test CI v2.1.53
Some checks failed
Go CI Pipeline / Security Scan (SCA - govulncheck) (push) Has been cancelled
Go CI Pipeline / Lint Code (push) Has been cancelled
Go CI Pipeline / Run Tests (push) Has been cancelled
Go CI Pipeline / Build Application (push) Successful in 1m1s
Go CI Pipeline / Build and Push Docker Image (push) Failing after 50s
Go CI Pipeline / Deploy to VPS (push) Failing after 16s

This commit is contained in:
phattt2901 2025-05-06 01:57:34 +07:00
parent abea70b343
commit cc8ffedd7e

View File

@ -113,16 +113,11 @@ jobs:
with:
name: server-binary # Tên artifact rõ ràng hơn
path: ./bin/server # Đường dẫn tới file binary
# ---- Job: Build & Push Docker Image ----
docker-build-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
env:
REGISTRY: gitea.tuvanwebsite.com
# Chạy sau khi job 'build' (tạo binary) thành công
needs: [build]
# Chỉ chạy khi push vào nhánh master (không chạy cho PR)
# Kiểm tra lại biến context của Gitea Actions, có thể là 'gitea.ref_name' hoặc 'github.ref_name'
if: gitea.ref_name == 'master' || startsWith(gitea.ref_name, 'v')
steps:
- name: Checkout code # Cần checkout để lấy Dockerfile.prod
@ -165,16 +160,10 @@ jobs:
deploy:
name: Deploy to VPS
runs-on: ubuntu-latest
needs: [docker-build-push]
env:
REGISTRY: ${{ secrets.REGISTRY_URL }}
# Chỉ chạy khi push vào nhánh master
if: gitea.ref_name == 'master' || startsWith(gitea.ref_name, 'v')
steps:
# Lấy thông tin image vừa push
# Lưu ý: Kiểm tra lại biến context chính xác của Gitea Actions
- name: Set image name
run: echo "IMAGE_NAME=${{ secrets.REGISTRY_URL }}/${{ gitea.repository }}:${{ gitea.ref_name }}" >> $GITHUB_ENV
run: echo "IMAGE_NAME=${{ secrets.REGISTRY_URL }}/${{ gitea.repository }}:${{ gitea.ref_name }}" >> $GITEA_ENV
- name: Cài Docker CLI
run: |
apt-get update
@ -182,6 +171,9 @@ jobs:
docker version
- name: Deploy using Docker commands
run: |
sudo apt-get update
sudo apt-get install -y curl
curl -v https://${{ secrets.REGISTRY_URL }} || echo "Curl failed"
echo "Deploying image: ${{ env.IMAGE_NAME }}"
# Kéo image mới nhất về VPS host (thông qua runner)
docker pull ${{ env.IMAGE_NAME }}