72 lines
1.7 KiB
YAML
72 lines
1.7 KiB
YAML
pipeline:
|
|
# Test stage
|
|
test:
|
|
image: node:22-alpine
|
|
commands:
|
|
- npm ci
|
|
- npm run test:smoke
|
|
- npm run test:links
|
|
|
|
# Build stage
|
|
build:
|
|
image: node:22-alpine
|
|
commands:
|
|
- npm ci
|
|
- npm run build
|
|
when:
|
|
branch: [main, master]
|
|
event: [push, tag]
|
|
|
|
# Build and push Docker image
|
|
docker-build:
|
|
image: docker:24-dind
|
|
environment:
|
|
- DOCKER_HOST=tcp://docker:2375
|
|
commands:
|
|
- docker build -t mintel-website:${CI_COMMIT_SHA} -f docker/Dockerfile .
|
|
- docker tag mintel-website:${CI_COMMIT_SHA} ${REGISTRY_URL}:latest
|
|
when:
|
|
branch: [main, master]
|
|
event: [push, tag]
|
|
|
|
# Deploy to Hetzner
|
|
deploy:
|
|
image: appleboy/ssh-action
|
|
environment:
|
|
- SSH_KEY=${SSH_PRIVATE_KEY}
|
|
commands:
|
|
- echo "$SSH_PRIVATE_KEY" > /tmp/deploy_key
|
|
- chmod 600 /tmp/deploy_key
|
|
- ssh -o StrictHostKeyChecking=no -i /tmp/deploy_key ${DEPLOY_USER}@${DEPLOY_HOST} "
|
|
cd /opt/mintel &&
|
|
echo '${REGISTRY_URL}:latest' > .env.deploy &&
|
|
docker-compose pull &&
|
|
docker-compose up -d --remove-orphans &&
|
|
docker system prune -f"
|
|
when:
|
|
branch: [main, master]
|
|
event: [push]
|
|
|
|
# Services
|
|
services:
|
|
docker:
|
|
image: docker:24-dind
|
|
privileged: true
|
|
environment:
|
|
- DOCKER_TLS_CERTDIR=/certs
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
|
|
# Notifications
|
|
notify:
|
|
- name: slack
|
|
image: plugins/slack
|
|
settings:
|
|
webhook: ${SLACK_WEBHOOK}
|
|
channel: deployments
|
|
template: |
|
|
🚀 Mintel Blog Deployed!
|
|
Branch: {{CI_COMMIT_BRANCH}}
|
|
Commit: {{CI_COMMIT_SHA}}
|
|
Author: {{CI_COMMIT_AUTHOR}}
|
|
URL: https://mintel.me |