74 lines
2.2 KiB
YAML
74 lines
2.2 KiB
YAML
steps:
|
|
# 1. Build & Push Image
|
|
build-and-push:
|
|
image: plugins/docker
|
|
settings:
|
|
registry: git.exavolt.web.id
|
|
repo: git.exavolt.web.id/fikri/fullstack-portfolio
|
|
dockerfile: Dockerfile
|
|
use_cache: true
|
|
purge: false
|
|
username:
|
|
from_secret: gitea_user
|
|
password:
|
|
from_secret: gitea_token
|
|
when:
|
|
branch: master
|
|
event: push
|
|
|
|
# 2. Deploy via SSH
|
|
deploy:
|
|
image: appleboy/drone-ssh
|
|
settings:
|
|
host: 103.197.190.44
|
|
username: exavolt
|
|
port: 22
|
|
key:
|
|
from_secret: ssh_key
|
|
envs: [ gitea_user, gitea_token ]
|
|
gitea_user:
|
|
from_secret: gitea_user
|
|
gitea_token:
|
|
from_secret: gitea_token
|
|
script:
|
|
- cd ~/projects/fikri-fullstack-portfolio
|
|
- echo $gitea_token | docker login git.exavolt.web.id -u $gitea_user --password-stdin
|
|
- docker compose pull
|
|
- docker compose up -d --remove-orphans
|
|
- docker image prune -f
|
|
when:
|
|
branch: master
|
|
event: push
|
|
|
|
# 3. Notification Debugging Stage
|
|
notify-telegram:
|
|
image: alpine
|
|
environment:
|
|
TELEGRAM_TOKEN:
|
|
from_secret: telegram_token
|
|
TELEGRAM_CHAT_ID:
|
|
from_secret: telegram_chat_id
|
|
commands:
|
|
- apk add --no-cache curl > /dev/null 2>&1
|
|
- |
|
|
# Gunakan $ Tanpa Kurung Kurawal untuk memanggil Env OS Alpine
|
|
# Ini mencegah Woodpecker mengosongkan variabel secara tidak sengaja
|
|
|
|
if [ "$CI_PIPELINE_STATUS" = "success" ]; then
|
|
ICON="✅"
|
|
TEXT="SUCCESS"
|
|
else
|
|
ICON="❌"
|
|
TEXT="FAILED"
|
|
fi
|
|
|
|
# Kirim menggunakan format yang lebih strict
|
|
curl -X POST "https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage" \
|
|
-d "chat_id=$TELEGRAM_CHAT_ID" \
|
|
-d "message_thread_id=8" \
|
|
-d "parse_mode=HTML" \
|
|
-d "text=$ICON <b>Deployment $TEXT!</b>%0A%0A<b>📦 Project:</b> <code>$CI_REPO_NAME</code>%0A<b>🌿 Branch:</b> <code>$CI_COMMIT_BRANCH</code>%0A<b>📝 Commit:</b> <i>$CI_COMMIT_MESSAGE</i>%0A%0A🔗 <a href='$CI_PIPELINE_FORGE_URL'>Lihat Detail Log</a>"
|
|
when:
|
|
branch: master
|
|
event: push
|
|
status: [ success, failure ] |