Skip to content

Commit 1449177

Browse files
authored
fix: ci-cd for staging (#1)
* Delete test-mcp.js * fix: ci-cd for staging * Use docker-compose.yml in staging workflow Replace references to docker-compose.staging.yml with docker-compose.yml in .github/workflows/docker-build-staging.yml. This ensures the staging CI uses the generic compose file for both the docker-compose and docker compose command paths, simplifying configuration and avoiding filename mismatches. * Update docker-build-staging.yml * upd * upd
1 parent 14dd9fc commit 1449177

File tree

5 files changed

+30
-174
lines changed

5 files changed

+30
-174
lines changed

.github/workflows/docker-build-staging.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,38 +67,48 @@ jobs:
6767

6868
- name: Deploy to VPS via SSH
6969
uses: appleboy/ssh-action@v1.0.0
70+
env:
71+
REGISTRY: ${{ env.REGISTRY }}
72+
IMAGE_NAME: ${{ env.IMAGE_NAME }}
73+
GITHUB_SHA: ${{ github.sha }}
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
GITHUB_ACTOR: ${{ github.actor }}
7076
with:
7177
host: ${{ secrets.VPS_HOST }}
7278
username: ${{ secrets.VPS_USERNAME }}
7379
password: ${{ secrets.VPS_PASSWORD }}
7480
port: ${{ secrets.VPS_PORT }}
81+
envs: REGISTRY,IMAGE_NAME,GITHUB_SHA,GITHUB_TOKEN,GITHUB_ACTOR
7582
script: |
7683
set -e
7784
7885
# Navigate to staging project directory
7986
cd /opt/mcp-stag
8087
88+
# Remove any GitHub workflow files that might interfere
89+
sudo rm -rf .github/ || true
90+
8191
# Login to GitHub Container Registry
82-
echo ${{ secrets.GITHUB_TOKEN }} | sudo docker login ghcr.io -u ${{ github.actor }} --password-stdin
92+
echo ${GITHUB_TOKEN} | sudo docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
93+
94+
# Get short SHA (first 7 characters)
95+
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
8396
8497
# Pull the staging image
85-
sudo docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging-${{ github.sha }}
98+
sudo docker pull ${REGISTRY}/${IMAGE_NAME}:staging-${SHORT_SHA}
8699
87100
# Detect docker-compose version and use appropriate command
88101
if command -v docker-compose &> /dev/null; then
89-
COMPOSE_CMD="sudo docker-compose -f docker-compose.staging.yml"
102+
COMPOSE_CMD="docker-compose -f docker-compose.staging.yml"
90103
else
91-
COMPOSE_CMD="sudo docker compose -f docker-compose.staging.yml"
104+
COMPOSE_CMD="docker compose -f docker-compose.staging.yml"
92105
fi
93106
94107
# Stop and remove old containers
95-
$COMPOSE_CMD down || true
96-
97-
# Set image tag for staging deployment
98-
export IMAGE_TAG=staging-${{ github.sha }}
108+
sudo $COMPOSE_CMD down || true
99109
100-
# Start services with the new staging image
101-
$COMPOSE_CMD up -d
110+
# Start services with the new staging image (pass IMAGE_TAG inline)
111+
sudo IMAGE_TAG=staging-${SHORT_SHA} $COMPOSE_CMD up -d
102112
103113
# Wait for services to be healthy
104114
echo "Waiting for staging services to start..."

docker-compose.staging.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
version: '3.8'
21

32
services:
43
iot-cloud-mcp-staging:
5-
image: ghcr.io/dadadadas111/iot-cloud-mcp:${IMAGE_TAG:-staging-latest}
4+
image: ghcr.io/dadadadas111/iot-cloud-mcp:${IMAGE_TAG}
65
container_name: iot-cloud-mcp-staging
76
restart: unless-stopped
87
ports:

package-lock.json

Lines changed: 8 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mcp/mcp.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ import { RedisService } from '@/mcp/services/redis.service';
88
@Module({
99
imports: [HttpModule, AuthModule],
1010
providers: [McpService, ApiClientService, RedisService],
11-
exports: [McpService],
11+
exports: [McpService, ApiClientService],
1212
})
1313
export class McpModule {}

0 commit comments

Comments
 (0)