refactor: Update Woodpecker CI configuration to use steps, change image repository, and refine secret handling for deployment.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -1,25 +1,22 @@
|
|||||||
pipeline:
|
steps:
|
||||||
# 1. Build & Push Image ke Gitea Container Registry
|
# 1. Build & Push Image
|
||||||
# Kita menggunakan plugin/docker agar Woodpecker melakukan build Dockerfile Anda
|
|
||||||
build-and-push:
|
build-and-push:
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
# URL Gitea Anda
|
|
||||||
registry: git.exavolt.web.id
|
registry: git.exavolt.web.id
|
||||||
# Format: git.exavolt.web.id/username/repo-name
|
repo: git.exavolt.web.id/fikri/portfolio-app
|
||||||
repo: git.exavolt.web.id/fikri/fullstack-portfolio
|
dockerfile: Dockerfile
|
||||||
|
use_cache: true
|
||||||
|
# Gunakan environment otomatis untuk plugin docker
|
||||||
username:
|
username:
|
||||||
from_secret: gitea_user
|
from_secret: gitea_user
|
||||||
password:
|
password:
|
||||||
from_secret: gitea_token
|
from_secret: gitea_token
|
||||||
dockerfile: Dockerfile
|
|
||||||
# Menggunakan cache agar build berikutnya lebih cepat
|
|
||||||
use_cache: true
|
|
||||||
when:
|
when:
|
||||||
branch: main
|
branch: main
|
||||||
event: push
|
event: push
|
||||||
|
|
||||||
# 2. Deploy ke VPS via SSH
|
# 2. Deploy via SSH
|
||||||
deploy:
|
deploy:
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
settings:
|
settings:
|
||||||
@@ -28,18 +25,20 @@ pipeline:
|
|||||||
key:
|
key:
|
||||||
from_secret: ssh_key
|
from_secret: ssh_key
|
||||||
port: 22
|
port: 22
|
||||||
|
# Kita kirim variabel gitea ke dalam script SSH
|
||||||
|
envs: [GITEA_USER, GITEA_TOKEN]
|
||||||
script:
|
script:
|
||||||
# Pindah ke folder tempat docker-compose.yml berada di VPS
|
- cd ~/projects/fikri-fullstack-portfolio
|
||||||
- cd ~/portfolio
|
|
||||||
# Login ke Gitea Registry (diperlukan untuk pull image)
|
|
||||||
- echo $GITEA_TOKEN | docker login git.exavolt.web.id -u $GITEA_USER --password-stdin
|
- echo $GITEA_TOKEN | docker login git.exavolt.web.id -u $GITEA_USER --password-stdin
|
||||||
# Tarik image terbaru yang baru saja di-build
|
|
||||||
- docker compose pull
|
- docker compose pull
|
||||||
# Restart container dengan image baru
|
|
||||||
- docker compose up -d --remove-orphans
|
- docker compose up -d --remove-orphans
|
||||||
# Membersihkan image lama yang tidak terpakai (dangling)
|
|
||||||
- docker image prune -f
|
- docker image prune -f
|
||||||
secrets: [ gitea_user, gitea_token, ssh_key ]
|
environment:
|
||||||
|
# Mendefinisikan variabel agar bisa dibaca oleh 'envs' di atas
|
||||||
|
GITEA_USER:
|
||||||
|
from_secret: gitea_user
|
||||||
|
GITEA_TOKEN:
|
||||||
|
from_secret: gitea_token
|
||||||
when:
|
when:
|
||||||
branch: main
|
branch: main
|
||||||
event: push
|
event: push
|
||||||
Reference in New Issue
Block a user