[tag]staging

parent dd266982
Pipeline #48856 passed with stage
in 35 seconds
stages:
- deploy
variables:
APP_PATH: "$CI_PROJECT_DIR"
PM2_CONFIG: "$CI_PROJECT_DIR/pm2-be.config.js"
STAGING_URL: "https://vietprodev.duckdns.org/gateway/trainee-schedule-backend"
HEALTH_URL: "$STAGING_URL/health"
# Deploy to Staging
deploy:
stage: deploy
before_script:
- mkdir -p storage/log || true
- check=$(echo "$CI_COMMIT_MESSAGE" | sed -nE 's/^.*(\[tag\]staging).*$/\1/p')
- |
if [ "$check" != "[tag]staging" ]; then
echo "Commit message does not contain [tag]staging → skip pipeline"
exit 0
fi
script:
- cp /mnt/data/trainee-schedule-backend/.env $CI_PROJECT_DIR/.env
- pnpm install --no-frozen-lockfile
- pnpm build:staging
- pm2 delete trainee-schedule-backend || true
- pm2 start $PM2_CONFIG
- sleep 10
- pm2 status trainee-schedule-backend | grep -q "online" || (echo "Server did not start successfully"; exit 1)
only:
- release/staging
environment:
name: staging
url: $STAGING_URL
tags:
- runner-vpd-que
module.exports = {
apps: [
{
name: "trainee-schedule-backend",
script: "node",
args: "dist/index.js",
autorestart: true,
watch: false,
max_restarts: 10,
instances: 1,
exec_mode: 'fork',
env: {
NODE_ENV: "staging",
PORT: 3010,
},
env_file: ".env",
merge_logs: true
}
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment