260323:1333 fix CI : Verify relaase : 🐋 Login to Internal Registry #04
This commit is contained in:
+2
-47
@@ -54,53 +54,10 @@ jobs:
|
|||||||
cd ../frontend && pnpm build
|
cd ../frontend && pnpm build
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# JOB 2 : Build & Push Image (Release Stage)
|
# JOB 2 : Deploy — Trigger Blue-Green on QNAP
|
||||||
# ============================================================
|
|
||||||
release:
|
|
||||||
needs: build
|
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
|
||||||
- name: 📥 Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 🏷️ Get Version
|
|
||||||
id: pkg-version
|
|
||||||
run: |
|
|
||||||
VERSION=$(node -p "require('./backend/package.json').version")
|
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "Releasing version: $VERSION"
|
|
||||||
|
|
||||||
- name: 🐋 Login to Gitea Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: git.np-dms.work
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Backend
|
|
||||||
run: |
|
|
||||||
docker build -f backend/Dockerfile \
|
|
||||||
-t git.np-dms.work/${{ github.repository_owner }}/lcbp3-backend:${{ steps.pkg-version.outputs.VERSION }} \
|
|
||||||
-t git.np-dms.work/${{ github.repository_owner }}/lcbp3-backend:latest .
|
|
||||||
docker push git.np-dms.work/${{ github.repository_owner }}/lcbp3-backend:${{ steps.pkg-version.outputs.VERSION }}
|
|
||||||
docker push git.np-dms.work/${{ github.repository_owner }}/lcbp3-backend:latest
|
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Frontend
|
|
||||||
run: |
|
|
||||||
docker build -f frontend/Dockerfile \
|
|
||||||
--build-arg NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }} \
|
|
||||||
-t git.np-dms.work/${{ github.repository_owner }}/lcbp3-frontend:${{ steps.pkg-version.outputs.VERSION }} \
|
|
||||||
-t git.np-dms.work/${{ github.repository_owner }}/lcbp3-frontend:latest .
|
|
||||||
docker push git.np-dms.work/${{ github.repository_owner }}/lcbp3-frontend:${{ steps.pkg-version.outputs.VERSION }}
|
|
||||||
docker push git.np-dms.work/${{ github.repository_owner }}/lcbp3-frontend:latest
|
|
||||||
|
|
||||||
# ============================================================
|
|
||||||
# JOB 3 : Deploy — Trigger Blue-Green on QNAP
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
deploy:
|
deploy:
|
||||||
needs: release
|
needs: build
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -130,6 +87,4 @@ jobs:
|
|||||||
echo "🚀 Executing Blue-Green deployment..."
|
echo "🚀 Executing Blue-Green deployment..."
|
||||||
# Pass registry credentials if needed by the pull command in deploy.sh
|
# Pass registry credentials if needed by the pull command in deploy.sh
|
||||||
export DB_PASSWORD="${{ secrets.DB_PASSWORD }}"
|
export DB_PASSWORD="${{ secrets.DB_PASSWORD }}"
|
||||||
export REGISTRY_USER="${{ github.repository_owner }}"
|
|
||||||
export REGISTRY_TOKEN="${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
./scripts/deploy.sh
|
./scripts/deploy.sh
|
||||||
|
|||||||
+18
-12
@@ -43,21 +43,27 @@ docker exec lcbp3-mariadb mysqldump -u root -p"${DB_PASSWORD}" lcbp3_dms > "$BAC
|
|||||||
gzip "$BACKUP_FILE"
|
gzip "$BACKUP_FILE"
|
||||||
echo "✓ Backup created: $BACKUP_FILE.gz"
|
echo "✓ Backup created: $BACKUP_FILE.gz"
|
||||||
|
|
||||||
# Step 2: Pull latest images from registry
|
# Step 2: Build latest images directly on QNAP
|
||||||
echo "[2/9] Pulling latest Docker images from internal registry..."
|
echo "[2/9] Building latest Docker images from source..."
|
||||||
cd "$LCBP3_DIR/$TARGET"
|
cd "/share/np-dms/app/source/lcbp3"
|
||||||
|
|
||||||
if [ -n "$REGISTRY_TOKEN" ] && [ -n "$REGISTRY_USER" ]; then
|
# Extract API_URL for Frontend Build Argument
|
||||||
echo "Logging into Gitea Container Registry..."
|
API_URL="https://lcbp3-dms.example.com/api"
|
||||||
echo "$REGISTRY_TOKEN" | docker login git.np-dms.work -u "$REGISTRY_USER" --password-stdin
|
if [ -f "$LCBP3_DIR/$TARGET/.env.production" ]; then
|
||||||
|
ENV_URL=$(grep NEXT_PUBLIC_API_URL "$LCBP3_DIR/$TARGET/.env.production" | cut -d '=' -f2)
|
||||||
echo "Updating docker-compose.yml to use Gitea registry images..."
|
[ -n "$ENV_URL" ] && API_URL="$ENV_URL"
|
||||||
sed -i -E "s|image: (git\.np-dms\.work/[^/]+/)?lcbp3-backend|image: git.np-dms.work/$REGISTRY_USER/lcbp3-backend|g" docker-compose.yml
|
|
||||||
sed -i -E "s|image: (git\.np-dms\.work/[^/]+/)?lcbp3-frontend|image: git.np-dms.work/$REGISTRY_USER/lcbp3-frontend|g" docker-compose.yml
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker-compose pull
|
echo "Building backend..."
|
||||||
echo "✓ Images pulled"
|
docker build -f backend/Dockerfile -t lcbp3-backend:latest .
|
||||||
|
|
||||||
|
echo "Building frontend with API URL: $API_URL..."
|
||||||
|
docker build -f frontend/Dockerfile --build-arg NEXT_PUBLIC_API_URL="$API_URL" -t lcbp3-frontend:latest .
|
||||||
|
|
||||||
|
echo "✓ Images built successfully"
|
||||||
|
|
||||||
|
# Move correctly to target directory for docker-compose up
|
||||||
|
cd "$LCBP3_DIR/$TARGET"
|
||||||
|
|
||||||
# Step 3: Update configuration
|
# Step 3: Update configuration
|
||||||
echo "[3/9] Updating configuration..."
|
echo "[3/9] Updating configuration..."
|
||||||
|
|||||||
Reference in New Issue
Block a user