From 6714ef50114dc3681f76fa6c87627c28d495e1c7 Mon Sep 17 00:00:00 2001 From: phuongdm Date: Sun, 10 May 2026 23:43:58 +0700 Subject: [PATCH] fix CD part 7 --- .gitea/workflows/deploy-staging.yml | 54 ++++++++--------------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/.gitea/workflows/deploy-staging.yml b/.gitea/workflows/deploy-staging.yml index b8fb499..486930d 100644 --- a/.gitea/workflows/deploy-staging.yml +++ b/.gitea/workflows/deploy-staging.yml @@ -11,49 +11,25 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Build & Save Image + - name: Build Image run: | IMAGE="${{ secrets.IMAGE_NAME }}" if [ -z "$IMAGE" ]; then IMAGE="ttmt-frontend"; fi IMAGE=$(echo "$IMAGE" | tr '[:upper:]' '[:lower:]') docker build --build-arg NODE_VERSION=22.14.0 -t $IMAGE:staging-${{ github.sha }} . - docker save -o ./ttmt-frontend.tar $IMAGE:staging-${{ github.sha }} - - name: Upload Image Tar - env: - SSH_HOST: ${{ secrets.SSH_HOST }} - SSH_PORT: ${{ secrets.SSH_PORT }} - SSH_USER: ${{ secrets.SSH_USER }} - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + - name: Deploy local (docker compose) run: | - pwd - ls -lah - ls -lah ./ttmt-frontend.tar - mkdir -p ~/.ssh - printf '%s' "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - SSH_PORT="${SSH_PORT:-22}" - scp -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P "$SSH_PORT" ./ttmt-frontend.tar "$SSH_USER@$SSH_HOST:/tmp/ttmt-frontend.tar" - - - name: Deploy on target (docker compose) - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.SSH_HOST }} - username: ${{ secrets.SSH_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - port: ${{ secrets.SSH_PORT }} - script: | - IMAGE="${{ secrets.IMAGE_NAME }}" - if [ -z "$IMAGE" ]; then IMAGE="ttmt-frontend"; fi - IMAGE=$(echo "$IMAGE" | tr '[:upper:]' '[:lower:]') - COMPOSE_FILE=/home/compmanage/docker-compose.yml - OVERRIDE_FILE=/tmp/ttmt-frontend.override.yml - docker load -i /tmp/ttmt-frontend.tar - cat > $OVERRIDE_FILE < $OVERRIDE_FILE <