my-devops-client/.gitlab-ci.yml

29 lines
1.2 KiB
YAML

stages:
- test
- deploy
# -----------------------------------------------------------------
# Stage 1: DevSecOps Vulnerability Scanning
# -----------------------------------------------------------------
security_scan:
stage: test
image:
name: aquasec/trivy:0.49.1
entrypoint: [""]
script:
- trivy image --severity HIGH,CRITICAL nginxdemos/hello:plain-text
# -----------------------------------------------------------------
# Stage 2: Automated GitOps Deployment
# -----------------------------------------------------------------
deploy_application:
stage: deploy
image: docker:24.0.7-cli
script:
- docker pull nginxdemos/hello:plain-text
- docker compose -f ./stacks/hello-world/docker-compose.yml up -d
after_script:
- apk add --no-cache curl # این خط ابزار curl را به سرعت نصب می‌کند
- echo "=== STARTING TELEGRAM NOTIFICATION ==="
- echo "Target Chat ID is ${TELEGRAM_CHAT_ID}"
- curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" -d "chat_id=${TELEGRAM_CHAT_ID}" -d "parse_mode=Markdown" -d "text=🚀 *Deployment Succeeded!*%0A*Project:* ${CI_PROJECT_NAME}%0A*Commit:* ${CI_COMMIT_TITLE}"