fix CD workflow
Some checks failed
CI / build-test (push) Failing after 1m44s
Deploy Staging (Docker) / deploy (push) Failing after 47s

This commit is contained in:
Do Manh Phuong 2026-05-10 23:06:32 +07:00
parent 95bfaa3915
commit feb6c73bf9

View File

@ -11,28 +11,40 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Login Registry - name: Build & Save Image
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_URL }} -u ${{ secrets.REGISTRY_USER }} --password-stdin
- name: Build & Push
env: env:
IMAGE: ${{ secrets.REGISTRY_URL }}/${{ secrets.IMAGE_NAME }} IMAGE: ${{ secrets.IMAGE_NAME }}
run: | run: |
docker build --build-arg NODE_VERSION=22.14.0 -t $IMAGE:staging-${{ github.sha }} -t $IMAGE:staging-latest . docker build --build-arg NODE_VERSION=22.14.0 -t $IMAGE:staging-${{ github.sha }} .
docker push $IMAGE:staging-${{ github.sha }} docker save -o /tmp/ttmt-frontend.tar $IMAGE:staging-${{ github.sha }}
docker push $IMAGE:staging-latest
- name: Deploy local (docker compose) - name: Upload Image Tar
env: uses: appleboy/scp-action@v0.1.7
IMAGE: ${{ secrets.REGISTRY_URL }}/${{ secrets.IMAGE_NAME }} with:
run: | host: ${{ secrets.SSH_HOST }}
COMPOSE_FILE=/home/compmanage/docker-compose.yml username: ${{ secrets.SSH_USER }}
OVERRIDE_FILE=/tmp/ttmt-frontend.override.yml key: ${{ secrets.SSH_PRIVATE_KEY }}
cat > $OVERRIDE_FILE <<EOF port: ${{ secrets.SSH_PORT }}
services: source: /tmp/ttmt-frontend.tar
frontend: target: /tmp
image: $IMAGE:staging-${{ github.sha }}
EOF - name: Deploy on target (docker compose)
docker pull $IMAGE:staging-${{ github.sha }} uses: appleboy/ssh-action@v1.0.3
docker rm -f ttmt-frontend || true with:
docker compose -f $COMPOSE_FILE -f $OVERRIDE_FILE up -d --no-deps --force-recreate frontend host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
IMAGE=${{ secrets.IMAGE_NAME }}
COMPOSE_FILE=/home/compmanage/docker-compose.yml
OVERRIDE_FILE=/tmp/ttmt-frontend.override.yml
docker load -i /tmp/ttmt-frontend.tar
cat > $OVERRIDE_FILE <<EOF
services:
frontend:
image: $IMAGE:staging-${{ github.sha }}
EOF
docker rm -f ttmt-frontend || true
docker compose -f $COMPOSE_FILE -f $OVERRIDE_FILE up -d --no-deps --force-recreate frontend
rm -f /tmp/ttmt-frontend.tar $OVERRIDE_FILE